ATLAS Offline Software
Loading...
Searching...
No Matches
TrigTSerializer Class Reference

#include <TrigTSerializer.h>

Inheritance diagram for TrigTSerializer:
Collaboration diagram for TrigTSerializer:

Public Member Functions

 TrigTSerializer (const std::string &name, const std::string &type, const IInterface *parent)
virtual ~TrigTSerializer ()
StatusCode initialize ()
StatusCode finalize ()
std::vector< uint32_t > serialize (const std::string &nameOfClass, const void *instance)
 serializes an object of a class nameOfClass pointed to by instance and recursively also other objects which object may point to
void serialize (const std::string &nameOfClass, const void *instance, std::vector< uint32_t > &v)
 serializes an object of a class nameOfClass pointed to by instance and recursively also other objects which object may point to
void * deserialize (const std::string &nameOfClass, const std::vector< uint32_t > &v)
 deserializes an object of a class nameOfClass (and recursively other objects) found in std::vector<uint32_t>& v
StatusCode initClass (const std::string &nameOfClass) const
 initialize framework to be ready to serialize a given class method to be called to prevent delayed initializations on the first event
void reset ()
 clean internal serializer state.
StatusCode peekCLID (const std::vector< uint32_t > &v, uint32_t *guid) const
 access clid of the payload (stored in BS)
void setCLID (const uint32_t *guid)
 access clid of the payload virtual CLID getCLID() const = 0;
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

void do_persistify (const std::string &nameOfClass, void *instance)
void do_persistify_obj (const std::string &nameOfClass, void *instance)
void do_follow_ptr (const std::string &nameOfClass, void *instance)
void add_previous_streamerinfos ()
void prepareForTBuffer (const std::string &nameOfClass)
void restoreAfterTBuffer (const std::string &nameOfClass)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static bool streamerErrorHandler (Int_t level, Bool_t abort_bool, const char *location, const char *msg)
static bool bsDictWarningFilter (Int_t level, Bool_t abort_bool, const char *location, const char *msg)

Private Attributes

bool m_onlineMode
uint32_t m_guid [4]
uint32_t m_IgnoreErrLvl {}
std::map< std::string, uint32_t > m_errCount
StringArrayProperty m_ignoreMissingDicts
 IgnoreMissingDicts.
TList * m_streamersList
 Remember streamer info list for cleaning up later.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Static Private Attributes

static bool s_decodingError = false
static std::vector< std::string > s_dictsToIgnore
 static copy of the IgnoreMissingDicts property for the static error handler

Detailed Description

Author
Jiri Masik Jiri..nosp@m.Masi.nosp@m.k@cer.nosp@m.n.ch

Definition at line 37 of file TrigTSerializer.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TrigTSerializer()

TrigTSerializer::TrigTSerializer ( const std::string & name,
const std::string & type,
const IInterface * parent )

Definition at line 235 of file TrigTSerializer.cxx.

235 : AthAlgTool(toolname, type, parent), m_streamersList{nullptr} {
236 declareInterface<ITrigSerializerToolBase>( this );
237 declareProperty("OnlineMode", m_onlineMode=false, "avoid initializations not needed in the online");
238
239 for (size_t i=0; i<4; i++) m_guid[i]=0;
240}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
TList * m_streamersList
Remember streamer info list for cleaning up later.
uint32_t m_guid[4]

◆ ~TrigTSerializer()

TrigTSerializer::~TrigTSerializer ( )
virtual

Definition at line 242 of file TrigTSerializer.cxx.

242 {
243 if (m_streamersList){
244 delete m_streamersList;
245 m_streamersList = nullptr;
246 }
247}

Member Function Documentation

◆ add_previous_streamerinfos()

void TrigTSerializer::add_previous_streamerinfos ( )
private

Definition at line 303 of file TrigTSerializer.cxx.

304{
305 RootUtils::WithRootErrorHandler hand( bsDictWarningFilter );
306 //temporary
307 std::string extStreamerInfos = "bs-streamerinfos.root";
308 std::string extFile = PathResolver::find_file (extStreamerInfos, "DATAPATH");
309 ATH_MSG_DEBUG( "Using " << extFile );
310 TFile f(extFile.c_str());
311 m_streamersList = f.GetStreamerInfoList();
313 while (TObject* obj = nextinfo()) {
314 TStreamerInfo *inf = dynamic_cast<TStreamerInfo*> (obj);
315 if (!inf) continue;
316 TString t_name=inf->GetName();
317
318 if (t_name.BeginsWith("listOfRules")){
319 ATH_MSG_WARNING( "Could not re-load class " << t_name );
320 continue;
321 }
322
323 inf->BuildCheck();
324 //this triggers a crash on lcg60
325 TClass *cl = inf->GetClass();
326 if (cl)
327 ATH_MSG_DEBUG( "external TStreamerInfo for " << cl->GetName()
328 << " checksum: " << inf->GetCheckSum() );
329 }
330 f.Close();
331}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
static bool bsDictWarningFilter(Int_t level, Bool_t abort_bool, const char *location, const char *msg)
TStreamerInfo * inf
TIter nextinfo(a)
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]

◆ bsDictWarningFilter()

bool TrigTSerializer::bsDictWarningFilter ( Int_t level,
Bool_t abort_bool,
const char * location,
const char * msg )
staticprivate

Definition at line 286 of file TrigTSerializer.cxx.

288{
289 if( level == kWarning and gDebug == 0 ) {
290 if( strstr(msg, "no dictionary for class") ) {
291 for( std::string &type : s_dictsToIgnore ) {
292 if( strstr(msg, type.c_str()) ) {
293 return false;
294 }
295 }
296 }
297 }
298 DefaultErrorHandler(level,abort_bool, location, msg);
299 return false;
300}
MsgStream & msg() const
static std::vector< std::string > s_dictsToIgnore
static copy of the IgnoreMissingDicts property for the static error handler

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ deserialize()

void * TrigTSerializer::deserialize ( const std::string & nameOfClass,
const std::vector< uint32_t > & v )
virtual

deserializes an object of a class nameOfClass (and recursively other objects) found in std::vector<uint32_t>& v

Returns
pointer to a deserialized object

Implements ITrigSerializer.

Definition at line 477 of file TrigTSerializer.cxx.

477 {
478
479 size_t rootDebug = gDebug;
480 if (msgLvl(MSG::DEBUG)){
481 ATH_MSG_DEBUG( "in deserialize for " << nameOfClass );
482 /*
483 //cannot be used in production
484 //higher gDebug seems to interfere with ErrorHandler
485 if (m_outputlevel<=MSG::VERBOSE &&rootDebug<5)
486 gDebug=5;
487 */
488 }
489
490 const size_t vsize = v.size();
491 uint32_t rVersion(0);
492 size_t bufsiz(0);
493 bool newFormatOK=true;
494 bool decodeOldFormat=true;
495 size_t pBuffOffset(3); //adjust below
496 //
497 //
498
499 if (vsize>2){
500 if (v.at(0)==TRIGTSERHEADER){
501 rVersion = v.at(1);
502 bufsiz = v.at(2);
503 if (rVersion>3)
504 pBuffOffset++;
505 if (rVersion>4)
506 pBuffOffset += 3; //wrt ver 4
507
508 //check size with vsize
509 size_t expectsize = pBuffOffset + bufsiz/4 + bufsiz%4;
510
511 if (expectsize!=vsize){
512 newFormatOK = false;
513 ATH_MSG_WARNING( "expected payload length "<<expectsize
514 << " does not match the container size " << vsize
515 << " for " << nameOfClass << " fallback to the old format:" );
516 }
517 ATH_MSG_DEBUG( bufsiz << "bytes of payload version " << std::hex << rVersion << std::dec
518 << " for " << nameOfClass );
519 }
520 else {
521 ATH_MSG_WARNING( "not a versioned payload of "
522 << nameOfClass << " trying initial TrigTSerializer" );
523 newFormatOK = false;
524 }
525
526 } else {
527 ATH_MSG_WARNING( "zero bytes of payload for " << nameOfClass );
528 gDebug=rootDebug;
529 return NULL;
530 }
531
532 //
533 char *pbuf = NULL;
534
535 if (newFormatOK){
536 union {
538 char pp[4];
539 } pbytes;
540
541 // const size_t bufsiz = v.size();
542 pbuf = new char[bufsiz];
543 size_t bufpos=0;
544 const size_t nints = bufsiz/4;
545 for (size_t i=pBuffOffset; i<nints+pBuffOffset; i++){
546 pbytes.uint = v.at(i);
547 for (size_t c=0; c<4; c++){
548 pbuf[bufpos] = pbytes.pp[3-c];
549 bufpos++;
550 }
551 }
552
553 for (size_t i=nints+pBuffOffset; i<vsize; i++){
554 pbuf[bufpos] = (char)v.at(i);
555 bufpos++;
556 }
557
558 if (msgLvl(MSG::VERBOSE)){
559 msg(MSG::VERBOSE) << "deserialized dump: ";
560 for (size_t i=0; i<v.size(); i++){
561 msg(MSG::VERBOSE) << std::hex << v.at(i) <<std::dec << " ";
562 }
563 msg(MSG::VERBOSE) << endmsg;
564 }
565
566 } else if (!newFormatOK && decodeOldFormat){
567 bufsiz = v.size();
568 pbuf = new char[bufsiz];
569
570 for (size_t i=0; i<bufsiz; i++)
571 pbuf[i] = v.at(i);
572 } else {
573 gDebug=rootDebug;
574 return NULL;
575 }
576
577 /*
578 if (newFormatOK && rVersion >3)
579 setCLID(v.at(3));
580 */
581
582 //common part
583 TBufferFile *buff = new TBufferFile(TBuffer::kRead, bufsiz, pbuf, kTRUE);
584
585 std::string noc= TrigSerializeResult::remapToDictName(nameOfClass);
586 TClass *pclass = gROOT->GetClass(noc.c_str());
587
588 TObject *pobj = NULL;
589 if (pclass){
591 {
592 RootUtils::WithRootErrorHandler hand (streamerErrorHandler);
593 //pobj = (TObject *)(buff->ReadObjectAny(pclass));
594 pobj = (TObject *)(ROOT8367Workaround::TBufferFileWorkaround::doReadObjectAny (buff, pclass));
595 }
597 //ErrorHandlerFunc_t oldhandler= ::SetErrorHandler(streamerErrorHandler);
598 //SetErrorHandler(oldhandler);
599 //buff->StreamObject(instance, pclass);
600 }
601 else {
602 ATH_MSG_ERROR( "gROOT->GetClass failed for" << nameOfClass );
603 }
604
605 delete buff; //this also deletes pbuf owned by buff
606 gDebug=rootDebug;
607
608 return (void *)pobj;
609}
#define endmsg
#define ATH_MSG_ERROR(x)
unsigned int uint
#define TRIGTSERHEADER
bool msgLvl(const MSG::Level lvl) const
void restoreAfterTBuffer(const std::string &nameOfClass)
void prepareForTBuffer(const std::string &nameOfClass)
static bool streamerErrorHandler(Int_t level, Bool_t abort_bool, const char *location, const char *msg)
std::string remapToDictName(const std::string &s)
setEventNumber uint32_t

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ do_follow_ptr()

void TrigTSerializer::do_follow_ptr ( const std::string & nameOfClass,
void * instance )
private

Definition at line 668 of file TrigTSerializer.cxx.

668 {
669
670 ATH_MSG_VERBOSE("Entering do_follow_ptr for " << name << " at " << ptr );
671
672
673 if (ptr){
674 const std::string classname = name.substr(0, name.find_last_of('*'));
675 ATH_MSG_DEBUG( "going deeper for " << classname << " at " << ptr );
676 do_persistify(classname, ptr);
677 }
678
679}
#define ATH_MSG_VERBOSE(x)
void do_persistify(const std::string &nameOfClass, void *instance)

◆ do_persistify()

void TrigTSerializer::do_persistify ( const std::string & nameOfClass,
void * instance )
private

Definition at line 664 of file TrigTSerializer.cxx.

void TrigTSerializerUnimplError()

◆ do_persistify_obj()

void TrigTSerializer::do_persistify_obj ( const std::string & nameOfClass,
void * instance )
private

Definition at line 665 of file TrigTSerializer.cxx.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode TrigTSerializer::finalize ( )

Definition at line 270 of file TrigTSerializer.cxx.

270 {
271
272 std::map<std::string,uint32_t>::const_iterator mitr(m_errCount.begin());
273 std::map<std::string,uint32_t>::const_iterator mend(m_errCount.end());
274 bool reported(false);
275 while (mitr!=mend){
276 reported=true;
277 ATH_MSG_WARNING( "Could not interpret persistent object " << (*mitr).first
278 << " /" << (*mitr).second << " times." );
279 ++mitr;
280 }
281 if (!reported)
282 ATH_MSG_INFO( name() << " no problems encountered" );
283 return StatusCode::SUCCESS;
284}
#define ATH_MSG_INFO(x)
std::map< std::string, uint32_t > m_errCount

◆ initClass()

StatusCode TrigTSerializer::initClass ( const std::string & nameOfClass) const
virtual

initialize framework to be ready to serialize a given class method to be called to prevent delayed initializations on the first event

Returns
StatusCode

Implements ITrigSerializer.

Definition at line 612 of file TrigTSerializer.cxx.

612 {
613
614 TClass *pclass = gROOT->GetClass(nameOfClass.c_str());
615
616
617 StatusCode sc(StatusCode::FAILURE);
618
619 if (pclass)
620 sc = StatusCode::SUCCESS;
621
622
623 return sc;
624
625}
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ initialize()

StatusCode TrigTSerializer::initialize ( )

Definition at line 249 of file TrigTSerializer.cxx.

249 {
250 ATH_MSG_DEBUG( "TrigTSerializer::initialize " << name() );
251
252 // copy missing dictionary names from the property to the static member
253 s_dictsToIgnore.insert( std::end(s_dictsToIgnore), std::begin(m_ignoreMissingDicts.value()), std::end(m_ignoreMissingDicts.value()) );
254 std::string msg;
255 for( const auto& n:s_dictsToIgnore ) {
256 if( not msg.empty() ) msg += ", ";
257 msg += n;
258 }
259 ATH_MSG_DEBUG( "Suppressing missing dictionary warnings for: " << msg );
260
261 if (!m_onlineMode)
263
265
266 return StatusCode::SUCCESS;
267
268}
uint32_t m_IgnoreErrLvl
StringArrayProperty m_ignoreMissingDicts
IgnoreMissingDicts.
void add_previous_streamerinfos()

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ITrigSerializerToolBase::interfaceID ( )
inlinestaticinherited

Definition at line 92 of file ITrigSerializerToolBase.h.

static const InterfaceID IID_ITrigSerializerToolBase("ITrigSerializerToolBase", 1, 0)
Declaration of the interface ID ( interface id, major version, minor version)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ peekCLID()

StatusCode TrigTSerializer::peekCLID ( const std::vector< uint32_t > & v,
uint32_t * guid ) const
virtual

access clid of the payload (stored in BS)

Implements ITrigSerializer.

Definition at line 633 of file TrigTSerializer.cxx.

633 {
634 if (v.size()>2){
635 if (v.at(0)==TRIGTSERHEADER){
636 const uint32_t rVersion = v.at(1);
637 if (rVersion>4){
638 guid[0] = v.at(3);
639 guid[1] = v.at(4);
640 guid[2] = v.at(5);
641 guid[3] = v.at(6);
642 return StatusCode::SUCCESS;
643 }
644 }
645 }
646 return StatusCode::FAILURE;
647}

◆ prepareForTBuffer()

void TrigTSerializer::prepareForTBuffer ( const std::string & nameOfClass)
private

Definition at line 350 of file TrigTSerializer.cxx.

350 {
352 //MN: this setting does not play well with ROOTDEBUG:
353 // gErrorIgnoreLevel = kInfo+1;
354 //had this class a problem before?
355 if (m_errCount.find(nameOfClass)!=m_errCount.end()){
357 }
358 s_decodingError = false;
359}
static bool s_decodingError

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ reset()

void TrigTSerializer::reset ( )
virtual

clean internal serializer state.

To be used between (de)serialization of unrelated data (for example of a new event)

Implements ITrigSerializer.

Definition at line 629 of file TrigTSerializer.cxx.

629 {
630 m_guid[0] = m_guid[1] = m_guid[2] = m_guid[3] = 0;
631}

◆ restoreAfterTBuffer()

void TrigTSerializer::restoreAfterTBuffer ( const std::string & nameOfClass)
private

Definition at line 361 of file TrigTSerializer.cxx.

361 {
362 if (s_decodingError){
363 s_decodingError = false;
364
365
366 if (m_errCount.find(nameOfClass)!=m_errCount.end()){
367 ++m_errCount[nameOfClass];
368 } else {
369 ATH_MSG_ERROR( "Errors while decoding " << nameOfClass
370 << " any further ROOT messages for this class will be suppressed" );
371 m_errCount[nameOfClass] = 1;
372 }
373 }
374
376}

◆ serialize() [1/2]

std::vector< uint32_t > TrigTSerializer::serialize ( const std::string & nameOfClass,
const void * instance )
virtual

serializes an object of a class nameOfClass pointed to by instance and recursively also other objects which object may point to

Returns
std::vector<uint32_t>

Implements ITrigSerializer.

Definition at line 378 of file TrigTSerializer.cxx.

378 {
379 std::vector<uint32_t> serialized;
380 serialize(nameOfClass, instance, serialized);
381 return serialized;
382}
std::map< std::string, double > instance
std::vector< uint32_t > serialize(const std::string &nameOfClass, const void *instance)
serializes an object of a class nameOfClass pointed to by instance and recursively also other objects...

◆ serialize() [2/2]

void TrigTSerializer::serialize ( const std::string & nameOfClass,
const void * instance,
std::vector< uint32_t > & v )
virtual

serializes an object of a class nameOfClass pointed to by instance and recursively also other objects which object may point to

Returns
std::vector<uint32_t>

Implements ITrigSerializer.

Definition at line 384 of file TrigTSerializer.cxx.

384 {
385
386 serialized.clear();
387
388 size_t rootDebug = gDebug;
389
390 if (msgLvl(MSG::DEBUG)){
391 ATH_MSG_DEBUG( "in serialize for " << nameOfClass );
392 /*
393 //cannot be used in production
394 //higher gDebug seems to interfere with ErrorHandler
395 if (m_outputlevel<=MSG::VERBOSE && rootDebug<5)
396 gDebug=5;
397 */
398 }
399
400 std::string noc= TrigSerializeResult::remapToDictName(nameOfClass);
401 TClass *pclass = gROOT->GetClass(noc.c_str());
402
403 // do_persistify(noc, instance);
404
405 TBufferFile *buff = new TBufferFile(TBuffer::kWrite);
406
407 //std::vector<uint32_t> serialized;
408
409 if (pclass){
410 //buff->StreamObject(instance, pclass);
411
412 ATH_MSG_DEBUG( "writing instance " << instance << " to buffer for noc " << noc );
413
415 {
416 RootUtils::WithRootErrorHandler hand (streamerErrorHandler);
417 buff->WriteObjectAny(instance, pclass);
418 }
420
421 ATH_MSG_DEBUG( "wrote buffer of length " << buff->Length() );
422
423
424 const char *pbuff = buff->Buffer();
425 const size_t bufsiz = buff->Length();
426
427 serialized.push_back(TRIGTSERHEADER);
428 serialized.push_back(TRIGTSERVERSION);
429 serialized.push_back(bufsiz);
430 serialized.push_back(m_guid[0]);
431 serialized.push_back(m_guid[1]);
432 serialized.push_back(m_guid[2]);
433 serialized.push_back(m_guid[3]);
434
435 //inefficient - to be compatible with Serializer for the moment can be avoided later
436 union {
438 char pp[4];
439 } pbytes;
440
441 for (size_t i=0; i<bufsiz/4; i++){
442 pbytes.uint = 0;
443 for (size_t j=0; j<4; j++){
444 pbytes.pp[3-j] = pbuff[4*i+j];
445 }
446 // ATH_MSG_DEBUG( "packed " << std::hex << pbytes << std::dec );
447
448 serialized.push_back(pbytes.uint);
449 }
450
451 //send rest of chars as one int each
452 const size_t modb = bufsiz%4;
453 for (size_t i=0; i<modb; i++){
454 pbytes.uint = 0;
455 pbytes.pp[0] = pbuff[bufsiz-modb+i];
456 serialized.push_back(pbytes.uint);
457 }
458
459 if (msgLvl(MSG::VERBOSE)){
460 msg(MSG::VERBOSE) << "serialized dump: ";
461 for (size_t i=0; i<serialized.size(); i++){
462 msg(MSG::VERBOSE) << std::hex << serialized.at(i) <<std::dec << " ";
463 }
464 msg(MSG::VERBOSE) << endmsg;
465 }
466 }
467 else {
468 ATH_MSG_ERROR( "gROOT->GetClass failed for" << nameOfClass );
469 }
470
471 delete buff;
472 gDebug=rootDebug;
473
474 // return serialized;
475}
#define TRIGTSERVERSION

◆ setCLID()

void TrigTSerializer::setCLID ( const uint32_t * guid)
virtual

access clid of the payload virtual CLID getCLID() const = 0;

set clid of the persistent class to be stored in data

Implements ITrigSerializer.

Definition at line 649 of file TrigTSerializer.cxx.

649 {
650 for (size_t i=0; i<4; i++)
651 m_guid[i] = guid[i];
652}

◆ streamerErrorHandler()

bool TrigTSerializer::streamerErrorHandler ( Int_t level,
Bool_t abort_bool,
const char * location,
const char * msg )
staticprivate

Definition at line 334 of file TrigTSerializer.cxx.

335 {
336 if( level > kInfo ) {
337 //MN: ignore stuff below kWarning
338 s_decodingError = true;
339 }
340 int oldLvl = gErrorIgnoreLevel;
341 if( gDebug > 0 ) {
342 gErrorIgnoreLevel = kPrint;
343 }
344 ::DefaultErrorHandler(level,abort_bool, location, msg);
345 gErrorIgnoreLevel = oldLvl;
346
347 return false;
348}

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_errCount

std::map<std::string, uint32_t> TrigTSerializer::m_errCount
private

Definition at line 81 of file TrigTSerializer.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_guid

uint32_t TrigTSerializer::m_guid[4]
private

Definition at line 76 of file TrigTSerializer.h.

◆ m_IgnoreErrLvl

uint32_t TrigTSerializer::m_IgnoreErrLvl {}
private

Definition at line 80 of file TrigTSerializer.h.

80{};

◆ m_ignoreMissingDicts

StringArrayProperty TrigTSerializer::m_ignoreMissingDicts
private
Initial value:
{
this, "IgnoreMissingDicts", {},
"Suppress warining about missing dictionaries", "OrderedSet<std::string>" }

IgnoreMissingDicts.

Definition at line 84 of file TrigTSerializer.h.

84 {
85 this, "IgnoreMissingDicts", {},
86 "Suppress warining about missing dictionaries", "OrderedSet<std::string>" };

◆ m_onlineMode

bool TrigTSerializer::m_onlineMode
private

Definition at line 75 of file TrigTSerializer.h.

◆ m_streamersList

TList* TrigTSerializer::m_streamersList
private

Remember streamer info list for cleaning up later.

Definition at line 91 of file TrigTSerializer.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ s_decodingError

bool TrigTSerializer::s_decodingError = false
staticprivate

Definition at line 79 of file TrigTSerializer.h.

◆ s_dictsToIgnore

std::vector< std::string > TrigTSerializer::s_dictsToIgnore
staticprivate
Initial value:
= {
"CosmicMuonCollection_tlp1", "MdtTrackSegmentCollection_tlp1",
"CosmicMuonCollection_p1", "CosmicMuon_p1", "MdtTrackSegmentCollection_p1",
"MdtTrackSegment_p1", "MdtTrackSegmentCollection_p2", "PanTauDetails_p1",
"SG::IAuxStoreCompression"
}

static copy of the IgnoreMissingDicts property for the static error handler

Definition at line 228 of file TrigTSerializer.h.

264 : virtual public ITrigSerializerToolBase, public AthAlgTool {
265public:
266 TrigTSerializer(const std::string& name, const std::string& type,
267 const IInterface* parent);
268 virtual ~TrigTSerializer();
269
272
273 std::vector<uint32_t> serialize(const std::string &nameOfClass, const void* instance);
274
275 void serialize(const std::string &nameOfClass, const void* instance, std::vector<uint32_t> &v);
276
277 void* deserialize(const std::string &nameOfClass, const std::vector<uint32_t>& v);
278
279 StatusCode initClass(const std::string &nameOfClass) const;
280
281 //reset Serializer internal data between running serialize methods with unrelated data
282 void reset();
283
284 StatusCode peekCLID(const std::vector<uint32_t>& v, uint32_t *guid) const;
285
286 void setCLID(const uint32_t *guid);
287
288private:
289 void do_persistify(const std::string& nameOfClass, void* instance);
290 void do_persistify_obj(const std::string& nameOfClass, void* instance);
291 void do_follow_ptr(const std::string& nameOfClass, void* instance);
293
294 static bool streamerErrorHandler(Int_t level, Bool_t abort_bool,
295 const char* location, const char *msg);
296 static bool bsDictWarningFilter(Int_t level, Bool_t abort_bool,
297 const char* location, const char *msg);
298
299 void prepareForTBuffer(const std::string &nameOfClass);
300 void restoreAfterTBuffer(const std::string &nameOfClass);
301
302 bool m_onlineMode;
303 uint32_t m_guid[4];
304
305 // for error handling
306 static bool s_decodingError;
308 std::map<std::string, uint32_t> m_errCount;
309
311 StringArrayProperty m_ignoreMissingDicts {
312 this, "IgnoreMissingDicts", {},
313 "Suppress warining about missing dictionaries", "OrderedSet<std::string>" };
315 static std::vector<std::string> s_dictsToIgnore;
316
318 TList* m_streamersList;
319};
320
321#undef REFLEX_NS
322
323
324#endif
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
void reset()
clean internal serializer state.
StatusCode finalize()
void * deserialize(const std::string &nameOfClass, const std::vector< uint32_t > &v)
deserializes an object of a class nameOfClass (and recursively other objects) found in std::vector<ui...
StatusCode peekCLID(const std::vector< uint32_t > &v, uint32_t *guid) const
access clid of the payload (stored in BS)
StatusCode initialize()
void setCLID(const uint32_t *guid)
access clid of the payload virtual CLID getCLID() const = 0;
StatusCode initClass(const std::string &nameOfClass) const
initialize framework to be ready to serialize a given class method to be called to prevent delayed in...
void do_persistify_obj(const std::string &nameOfClass, void *instance)
TrigTSerializer(const std::string &name, const std::string &type, const IInterface *parent)
void do_follow_ptr(const std::string &nameOfClass, void *instance)

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