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< StoreGateSvc > StoreGateSvc_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 36 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 237 of file TrigTSerializer.cxx.

237 : AthAlgTool(toolname, type, parent), m_streamersList{nullptr} {
238 declareInterface<ITrigSerializerToolBase>( this );
239 declareProperty("OnlineMode", m_onlineMode=false, "avoid initializations not needed in the online");
240
241 for (size_t i=0; i<4; i++) m_guid[i]=0;
242}
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 244 of file TrigTSerializer.cxx.

244 {
245 if (m_streamersList){
246 delete m_streamersList;
247 m_streamersList = nullptr;
248 }
249}

Member Function Documentation

◆ add_previous_streamerinfos()

void TrigTSerializer::add_previous_streamerinfos ( )
private

Definition at line 305 of file TrigTSerializer.cxx.

306{
307 RootUtils::WithRootErrorHandler hand( bsDictWarningFilter );
308 //temporary
309 std::string extStreamerInfos = "bs-streamerinfos.root";
310 std::string extFile = PathResolver::find_file (extStreamerInfos, "DATAPATH");
311 ATH_MSG_DEBUG( "Using " << extFile );
312 TFile f(extFile.c_str());
313 m_streamersList = f.GetStreamerInfoList();
315 while (TObject* obj = nextinfo()) {
316 TStreamerInfo *inf = dynamic_cast<TStreamerInfo*> (obj);
317 if (!inf) continue;
318 TString t_name=inf->GetName();
319
320 if (t_name.BeginsWith("listOfRules")){
321 ATH_MSG_WARNING( "Could not re-load class " << t_name );
322 continue;
323 }
324
325 inf->BuildCheck();
326 //this triggers a crash on lcg60
327 TClass *cl = inf->GetClass();
328 if (cl)
329 ATH_MSG_DEBUG( "external TStreamerInfo for " << cl->GetName()
330 << " checksum: " << inf->GetCheckSum() );
331 }
332 f.Close();
333}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(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 288 of file TrigTSerializer.cxx.

290{
291 if( level == kWarning and gDebug == 0 ) {
292 if( strstr(msg, "no dictionary for class") ) {
293 for( std::string &type : s_dictsToIgnore ) {
294 if( strstr(msg, type.c_str()) ) {
295 return false;
296 }
297 }
298 }
299 }
300 DefaultErrorHandler(level,abort_bool, location, msg);
301 return false;
302}
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 479 of file TrigTSerializer.cxx.

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

663 {
664
665 ATH_MSG_VERBOSE("Entering do_follow_ptr for " << name << " at " << ptr );
666
667
668 if (ptr){
669 const std::string classname = name.substr(0, name.find_last_of('*'));
670 ATH_MSG_DEBUG( "going deeper for " << classname << " at " << ptr );
671 do_persistify(classname, ptr);
672 }
673
674}
#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 659 of file TrigTSerializer.cxx.

void TrigTSerializerUnimplError()

◆ do_persistify_obj()

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

Definition at line 660 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 272 of file TrigTSerializer.cxx.

272 {
273
274 std::map<std::string,uint32_t>::const_iterator mitr(m_errCount.begin());
275 std::map<std::string,uint32_t>::const_iterator mend(m_errCount.end());
276 bool reported(false);
277 while (mitr!=mend){
278 reported=true;
279 ATH_MSG_WARNING( "Could not interpret persistent object " << (*mitr).first
280 << " /" << (*mitr).second << " times." );
281 ++mitr;
282 }
283 if (!reported)
284 ATH_MSG_INFO( name() << " no problems encountered" );
285 return StatusCode::SUCCESS;
286}
#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 607 of file TrigTSerializer.cxx.

607 {
608
609 TClass *pclass = gROOT->GetClass(nameOfClass.c_str());
610
611
612 StatusCode sc(StatusCode::FAILURE);
613
614 if (pclass)
615 sc = StatusCode::SUCCESS;
616
617
618 return sc;
619
620}
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ initialize()

StatusCode TrigTSerializer::initialize ( )

Definition at line 251 of file TrigTSerializer.cxx.

251 {
252 ATH_MSG_DEBUG( "TrigTSerializer::initialize " << name() );
253
254 // copy missing dictionary names from the property to the static member
255 s_dictsToIgnore.insert( std::end(s_dictsToIgnore), std::begin(m_ignoreMissingDicts.value()), std::end(m_ignoreMissingDicts.value()) );
256 std::string msg;
257 for( const auto& n:s_dictsToIgnore ) {
258 if( not msg.empty() ) msg += ", ";
259 msg += n;
260 }
261 ATH_MSG_DEBUG( "Suppressing missing dictionary warnings for: " << msg );
262
263 if (!m_onlineMode)
265
267
268 return StatusCode::SUCCESS;
269
270}
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 628 of file TrigTSerializer.cxx.

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

◆ prepareForTBuffer()

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

Definition at line 352 of file TrigTSerializer.cxx.

352 {
354 //MN: this setting does not play well with ROOTDEBUG:
355 // gErrorIgnoreLevel = kInfo+1;
356 //had this class a problem before?
357 if (m_errCount.find(nameOfClass)!=m_errCount.end()){
359 }
360 s_decodingError = false;
361}
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 624 of file TrigTSerializer.cxx.

624 {
625 m_guid[0] = m_guid[1] = m_guid[2] = m_guid[3] = 0;
626}

◆ restoreAfterTBuffer()

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

Definition at line 363 of file TrigTSerializer.cxx.

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

◆ 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 380 of file TrigTSerializer.cxx.

380 {
381 std::vector<uint32_t> serialized;
382 serialize(nameOfClass, instance, serialized);
383 return serialized;
384}
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 386 of file TrigTSerializer.cxx.

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

◆ 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 644 of file TrigTSerializer.cxx.

644 {
645 for (size_t i=0; i<4; i++)
646 m_guid[i] = guid[i];
647}

◆ streamerErrorHandler()

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

Definition at line 336 of file TrigTSerializer.cxx.

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

◆ 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 >, and AthCheckedComponent<::AthAlgTool >.

◆ 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 80 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 75 of file TrigTSerializer.h.

◆ m_IgnoreErrLvl

uint32_t TrigTSerializer::m_IgnoreErrLvl {}
private

Definition at line 79 of file TrigTSerializer.h.

79{};

◆ m_ignoreMissingDicts

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

IgnoreMissingDicts.

Definition at line 83 of file TrigTSerializer.h.

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

◆ m_onlineMode

bool TrigTSerializer::m_onlineMode
private

Definition at line 74 of file TrigTSerializer.h.

◆ m_streamersList

TList* TrigTSerializer::m_streamersList
private

Remember streamer info list for cleaning up later.

Definition at line 90 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 78 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 230 of file TrigTSerializer.h.

265 : virtual public ITrigSerializerToolBase, public AthAlgTool {
266public:
267 TrigTSerializer(const std::string& name, const std::string& type,
268 const IInterface* parent);
269 virtual ~TrigTSerializer();
270
273
274 std::vector<uint32_t> serialize(const std::string &nameOfClass, const void* instance);
275
276 void serialize(const std::string &nameOfClass, const void* instance, std::vector<uint32_t> &v);
277
278 void* deserialize(const std::string &nameOfClass, const std::vector<uint32_t>& v);
279
280 StatusCode initClass(const std::string &nameOfClass) const;
281
282 //reset Serializer internal data between running serialize methods with unrelated data
283 void reset();
284
285 StatusCode peekCLID(const std::vector<uint32_t>& v, uint32_t *guid) const;
286
287 void setCLID(const uint32_t *guid);
288
289private:
290 void do_persistify(const std::string& nameOfClass, void* instance);
291 void do_persistify_obj(const std::string& nameOfClass, void* instance);
292 void do_follow_ptr(const std::string& nameOfClass, void* instance);
294
295 static bool streamerErrorHandler(Int_t level, Bool_t abort_bool,
296 const char* location, const char *msg);
297 static bool bsDictWarningFilter(Int_t level, Bool_t abort_bool,
298 const char* location, const char *msg);
299
300 void prepareForTBuffer(const std::string &nameOfClass);
301 void restoreAfterTBuffer(const std::string &nameOfClass);
302
303 bool m_onlineMode;
304 uint32_t m_guid[4];
305
306 // for error handling
307 static bool s_decodingError;
309 std::map<std::string, uint32_t> m_errCount;
310
312 StringArrayProperty m_ignoreMissingDicts {
313 this, "IgnoreMissingDicts", {},
314 "Suppress warining about missing dictionaries", "OrderedSet<std::string>" };
316 static std::vector<std::string> s_dictsToIgnore;
317
319 TList* m_streamersList;
320};
321
322#undef REFLEX_NS
323
324
325#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: