19#include "TBufferFile.h"
22#include "TMethodCall.h"
30#include "TStreamerInfo.h"
37#define TRIGTSERHEADER 0xf00dbeef
39#define TRIGTSERVERSION 0x0005U
65#include "TSchemaRuleSet.h"
71 static const TClass* invalidPtr =
reinterpret_cast<TClass*
>(std::intptr_t(-1));
94 R__ASSERT(IsReading());
100 UInt_t startpos = UInt_t(fBufCur-fBuffer);
104 TClass *clRef = ReadClass(clCast, &tag);
105 TClass *clOnfile = 0;
106 Int_t baseOffset = 0;
107 if (clRef && (clRef!=invalidPtr) && clCast) {
109 baseOffset = clRef->GetBaseClassOffset(clCast);
110 if (baseOffset == -1) {
113 if (!clCast->GetSchemaRules() ||
114 !clCast->GetSchemaRules()->HasRuleWithSourceClass(clRef->GetName()))
117 Error(
"ReadObject",
"got object of wrong class! requested %s but got %s",
118 clCast->GetName(), clRef->GetName());
120 CheckByteCount(startpos, tag, (TClass*)0);
127 clRef =
const_cast<TClass*
>(clCast);
130 if (clCast->GetState() > TClass::kEmulated && clRef->GetState() <= TClass::kEmulated) {
132 Error(
"ReadObject",
"trying to read an emulated class (%s) to store in a compiled pointer (%s)",
133 clRef->GetName(),clCast->GetName());
134 CheckByteCount(startpos, tag, (TClass*)0);
143 obj = (
char *) (Long_t)fMap->GetValue(startpos+
kMapOffset);
144 if (obj == (
void*) -1) obj = 0;
146 CheckByteCount(startpos, tag, (TClass*)0);
147 return (obj+baseOffset);
152 if (clRef == invalidPtr) {
153 if (fBufCur >= fBufMax)
return 0;
155 MapObject((TObject*) -1, startpos+
kMapOffset);
157 MapObject((
void*)0, 0, fMapCount);
158 CheckByteCount(startpos, tag, (TClass*)0);
166 tag += fDisplacement;
167 tag = CheckObject(tag, clCast);
169 if (tag > (UInt_t)fMap->GetSize()) {
170 Error(
"ReadObject",
"object tag too large, I/O buffer corrupted");
175 obj = (
char *) (Long_t)fMap->GetValue(tag);
176 clRef = (TClass*) (Long_t)fClassMap->GetValue(tag);
178 if (clRef && (clRef!=invalidPtr) && clCast) {
180 baseOffset = clRef->GetBaseClassOffset(clCast);
181 if (baseOffset == -1) {
182 Error(
"ReadObject",
"Got object of wrong class (Got %s while expecting %s)",
183 clRef->GetName(),clCast->GetName());
200 obj = (
char*)clRef->New();
202 Error(
"ReadObject",
"could not create object of class %s",
212 MapObject(obj, clRef, fMapCount);
215 clRef->Streamer( obj, *
this, clOnfile );
217 CheckByteCount(startpos, tag, clRef);
220 return obj+baseOffset;
229 "CosmicMuonCollection_tlp1",
"MdtTrackSegmentCollection_tlp1",
230 "CosmicMuonCollection_p1",
"CosmicMuon_p1",
"MdtTrackSegmentCollection_p1",
231 "MdtTrackSegment_p1",
"MdtTrackSegmentCollection_p2",
"PanTauDetails_p1",
232 "SG::IAuxStoreCompression"
236 declareInterface<ITrigSerializerToolBase>(
this );
239 for (
size_t i=0; i<4; i++)
m_guid[i]=0;
256 if( not
msg.empty() )
msg +=
", ";
266 return StatusCode::SUCCESS;
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);
277 ATH_MSG_WARNING(
"Could not interpret persistent object " << (*mitr).first
278 <<
" /" << (*mitr).second <<
" times." );
283 return StatusCode::SUCCESS;
287 const char* location,
const char *
msg)
289 if( level == kWarning and gDebug == 0 ) {
290 if( strstr(
msg,
"no dictionary for class") ) {
292 if( strstr(
msg,
type.c_str()) ) {
298 DefaultErrorHandler(level,abort_bool, location,
msg);
307 std::string extStreamerInfos =
"bs-streamerinfos.root";
310 TFile f(extFile.c_str());
314 TStreamerInfo *
inf =
dynamic_cast<TStreamerInfo*
> (obj);
316 TString t_name=
inf->GetName();
318 if (t_name.BeginsWith(
"listOfRules")){
325 TClass *cl =
inf->GetClass();
327 ATH_MSG_DEBUG(
"external TStreamerInfo for " << cl->GetName()
328 <<
" checksum: " <<
inf->GetCheckSum() );
335 const char* location,
const char *
msg){
336 if( level > kInfo ) {
340 int oldLvl = gErrorIgnoreLevel;
342 gErrorIgnoreLevel = kPrint;
344 ::DefaultErrorHandler(level,abort_bool, location,
msg);
345 gErrorIgnoreLevel = oldLvl;
356 gErrorIgnoreLevel = kError+1;
370 <<
" any further ROOT messages for this class will be suppressed" );
379 std::vector<uint32_t> serialized;
388 size_t rootDebug = gDebug;
401 TClass *pclass = gROOT->GetClass(noc.c_str());
405 TBufferFile *buff =
new TBufferFile(TBuffer::kWrite);
417 buff->WriteObjectAny(
instance, pclass);
421 ATH_MSG_DEBUG(
"wrote buffer of length " << buff->Length() );
424 const char *pbuff = buff->Buffer();
425 const size_t bufsiz = buff->Length();
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]);
441 for (
size_t i=0; i<bufsiz/4; i++){
443 for (
size_t j=0; j<4; j++){
444 pbytes.pp[3-j] = pbuff[4*i+j];
448 serialized.push_back(pbytes.uint);
452 const size_t modb = bufsiz%4;
453 for (
size_t i=0; i<modb; i++){
455 pbytes.pp[0] = pbuff[bufsiz-modb+i];
456 serialized.push_back(pbytes.uint);
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 <<
" ";
468 ATH_MSG_ERROR(
"gROOT->GetClass failed for" << nameOfClass );
479 size_t rootDebug = gDebug;
490 const size_t vsize = v.size();
491 uint32_t rVersion(0);
493 bool newFormatOK=
true;
494 bool decodeOldFormat=
true;
495 size_t pBuffOffset(3);
509 size_t expectsize = pBuffOffset + bufsiz/4 + bufsiz%4;
511 if (expectsize!=vsize){
514 <<
" does not match the container size " << vsize
515 <<
" for " << nameOfClass <<
" fallback to the old format:" );
517 ATH_MSG_DEBUG( bufsiz <<
"bytes of payload version " << std::hex << rVersion << std::dec
518 <<
" for " << nameOfClass );
522 << nameOfClass <<
" trying initial TrigTSerializer" );
542 pbuf =
new char[bufsiz];
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];
553 for (
size_t i=nints+pBuffOffset; i<vsize; i++){
554 pbuf[bufpos] = (char)v.at(i);
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 <<
" ";
566 }
else if (!newFormatOK && decodeOldFormat){
568 pbuf =
new char[bufsiz];
570 for (
size_t i=0; i<bufsiz; i++)
583 TBufferFile *buff =
new TBufferFile(TBuffer::kRead, bufsiz, pbuf, kTRUE);
586 TClass *pclass = gROOT->GetClass(noc.c_str());
588 TObject *pobj = NULL;
594 pobj = (TObject *)(ROOT8367Workaround::TBufferFileWorkaround::doReadObjectAny (buff, pclass));
602 ATH_MSG_ERROR(
"gROOT->GetClass failed for" << nameOfClass );
614 TClass *pclass = gROOT->GetClass(nameOfClass.c_str());
617 StatusCode
sc(StatusCode::FAILURE);
620 sc = StatusCode::SUCCESS;
636 const uint32_t rVersion = v.at(1);
642 return StatusCode::SUCCESS;
646 return StatusCode::FAILURE;
650 for (
size_t i=0; i<4; i++)
659 <<
"ERROR! method TrigTSerializer::" << __PRETTY_FUNCTION__
660 <<
" was removed during migration to ROOT6" << endl;
670 ATH_MSG_VERBOSE(
"Entering do_follow_ptr for " << name <<
" at " << ptr );
674 const std::string classname = name.substr(0, name.find_last_of(
'*'));
675 ATH_MSG_DEBUG(
"going deeper for " << classname <<
" at " << ptr );
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
void TrigTSerializerUnimplError()
Run a MT piece of code with an alternate root error handler.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
void * ReadObjectAnyNV(const TClass *)
static void *doReadObjectAny NO_SANITIZE_UNDEFINED(TBufferFile *buf, const TClass *cl)
Run a MT piece of code with an alternate root error handler.
static std::vector< std::string > s_dictsToIgnore
static copy of the IgnoreMissingDicts property for the static error handler
virtual ~TrigTSerializer()
void reset()
clean internal serializer state.
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...
TList * m_streamersList
Remember streamer info list for cleaning up later.
StringArrayProperty m_ignoreMissingDicts
IgnoreMissingDicts.
StatusCode peekCLID(const std::vector< uint32_t > &v, uint32_t *guid) const
access clid of the payload (stored in BS)
static bool s_decodingError
void add_previous_streamerinfos()
void setCLID(const uint32_t *guid)
access clid of the payload virtual CLID getCLID() const = 0;
static bool bsDictWarningFilter(Int_t level, Bool_t abort_bool, const char *location, const char *msg)
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...
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...
std::map< std::string, uint32_t > m_errCount
void restoreAfterTBuffer(const std::string &nameOfClass)
void prepareForTBuffer(const std::string &nameOfClass)
void do_persistify(const std::string &nameOfClass, void *instance)
void do_persistify_obj(const std::string &nameOfClass, void *instance)
static bool streamerErrorHandler(Int_t level, Bool_t abort_bool, const char *location, const char *msg)
TrigTSerializer(const std::string &name, const std::string &type, const IInterface *parent)
void do_follow_ptr(const std::string &nameOfClass, void *instance)
singleton-like access to IMessageSvc via open function and helper
std::string remapToDictName(const std::string &s)
Helper to disable undefined behavior sanitizer for a function.