19 #include "TBufferFile.h"
22 #include "TMethodCall.h"
30 #include "TStreamerInfo.h"
37 #define TRIGTSERHEADER 0xf00dbeef
39 #define TRIGTSERVERSION 0x0005U
65 #include "TSchemaRuleSet.h"
77 void* ReadObjectAnyNV (
const TClass*);
88 R__ASSERT(IsReading());
94 UInt_t startpos = UInt_t(fBufCur-fBuffer);
98 TClass *clRef = ReadClass(clCast, &
tag);
100 Int_t baseOffset = 0;
101 if (clRef && (clRef!=(TClass*)(-1)) && clCast) {
103 baseOffset = clRef->GetBaseClassOffset(clCast);
104 if (baseOffset == -1) {
107 if (!clCast->GetSchemaRules() ||
108 !clCast->GetSchemaRules()->HasRuleWithSourceClass(clRef->GetName()))
111 Error(
"ReadObject",
"got object of wrong class! requested %s but got %s",
112 clCast->GetName(), clRef->GetName());
114 CheckByteCount(startpos,
tag, (TClass*)0);
121 clRef =
const_cast<TClass*
>(clCast);
124 if (clCast->GetState() > TClass::kEmulated && clRef->GetState() <= TClass::kEmulated) {
126 Error(
"ReadObject",
"trying to read an emulated class (%s) to store in a compiled pointer (%s)",
127 clRef->GetName(),clCast->GetName());
128 CheckByteCount(startpos,
tag, (TClass*)0);
138 if (
obj == (
void*) -1)
obj = 0;
140 CheckByteCount(startpos,
tag, (TClass*)0);
141 return (
obj+baseOffset);
146 if (clRef == (TClass*) -1) {
147 if (fBufCur >= fBufMax)
return 0;
149 MapObject((TObject*) -1, startpos+
kMapOffset);
151 MapObject((
void*)0, 0, fMapCount);
152 CheckByteCount(startpos,
tag, (TClass*)0);
160 tag += fDisplacement;
161 tag = CheckObject(
tag, clCast);
163 if (
tag > (UInt_t)fMap->GetSize()) {
164 Error(
"ReadObject",
"object tag too large, I/O buffer corrupted");
169 obj = (
char *) (Long_t)fMap->GetValue(
tag);
170 clRef = (TClass*) (Long_t)fClassMap->GetValue(
tag);
172 if (clRef && (clRef!=(TClass*)(-1)) && clCast) {
174 baseOffset = clRef->GetBaseClassOffset(clCast);
175 if (baseOffset == -1) {
176 Error(
"ReadObject",
"Got object of wrong class (Got %s while expecting %s)",
177 clRef->GetName(),clCast->GetName());
194 obj = (
char*)clRef->New();
196 Error(
"ReadObject",
"could not create object of class %s",
206 MapObject(
obj, clRef, fMapCount);
209 clRef->Streamer(
obj, *
this, clOnfile );
211 CheckByteCount(startpos,
tag, clRef);
214 return obj+baseOffset;
223 "CosmicMuonCollection_tlp1",
"MdtTrackSegmentCollection_tlp1",
224 "CosmicMuonCollection_p1",
"CosmicMuon_p1",
"MdtTrackSegmentCollection_p1",
225 "MdtTrackSegment_p1",
"MdtTrackSegmentCollection_p2",
"PanTauDetails_p1",
226 "SG::IAuxStoreCompression"
230 declareInterface<ITrigSerializerToolBase>(
this );
231 declareProperty(
"OnlineMode", m_onlineMode=
false,
"avoid initializations not needed in the online");
233 for (
size_t i=0;
i<4;
i++) m_guid[
i]=0;
250 if( not
msg.empty() )
msg +=
", ";
260 return StatusCode::SUCCESS;
266 std::map<std::string,uint32_t>::const_iterator mitr(
m_errCount.begin());
267 std::map<std::string,uint32_t>::const_iterator mend(
m_errCount.end());
268 bool reported(
false);
271 ATH_MSG_WARNING(
"Could not interpret persistent object " << (*mitr).first
272 <<
" /" << (*mitr).second <<
" times." );
277 return StatusCode::SUCCESS;
281 const char* location,
const char *
msg)
283 if(
level == kWarning and gDebug == 0 ) {
284 if( strstr(
msg,
"no dictionary for class") ) {
286 if( strstr(
msg,
type.c_str()) ) {
292 DefaultErrorHandler(
level,abort_bool, location,
msg);
301 std::string extStreamerInfos =
"bs-streamerinfos.root";
304 TFile
f(extFile.c_str());
308 TStreamerInfo *
inf =
dynamic_cast<TStreamerInfo*
> (
obj);
310 TString t_name=
inf->GetName();
312 if (t_name.BeginsWith(
"listOfRules")){
319 TClass *
cl =
inf->GetClass();
322 <<
" checksum: " <<
inf->GetCheckSum() );
329 const char* location,
const char *
msg){
330 if(
level > kInfo ) {
338 ::DefaultErrorHandler(
level,abort_bool, location,
msg);
364 <<
" any further ROOT messages for this class will be suppressed" );
373 std::vector<uint32_t> serialized;
382 size_t rootDebug = gDebug;
395 TClass *pclass = gROOT->GetClass(noc.c_str());
399 TBufferFile *
buff =
new TBufferFile(TBuffer::kWrite);
418 const char *pbuff =
buff->Buffer();
419 const size_t bufsiz =
buff->Length();
423 serialized.push_back(bufsiz);
424 serialized.push_back(
m_guid[0]);
425 serialized.push_back(
m_guid[1]);
426 serialized.push_back(
m_guid[2]);
427 serialized.push_back(
m_guid[3]);
431 char *pp = (
char *)&pbytes;
433 for (
size_t i=0;
i<bufsiz/4;
i++){
435 for (
size_t j=0; j<4; j++){
436 *(pp+3-j) = pbuff[4*
i+j];
440 serialized.push_back(pbytes);
444 const size_t modb = bufsiz%4;
445 for (
size_t i=0;
i<modb;
i++){
447 *pp = pbuff[bufsiz-modb+
i];
448 serialized.push_back(pbytes);
453 for (
size_t i=0;
i<serialized.size();
i++){
460 ATH_MSG_ERROR(
"gROOT->GetClass failed for" << nameOfClass );
471 size_t rootDebug = gDebug;
482 const size_t vsize =
v.size();
485 bool newFormatOK=
true;
486 bool decodeOldFormat=
true;
487 size_t pBuffOffset(3);
501 size_t expectsize = pBuffOffset + bufsiz/4 + bufsiz%4;
503 if (expectsize!=vsize){
506 <<
" does not match the container size " << vsize
507 <<
" for " << nameOfClass <<
" fallback to the old format:" );
509 ATH_MSG_DEBUG( bufsiz <<
"bytes of payload version " << std::hex << rVersion << std::dec
510 <<
" for " << nameOfClass );
514 << nameOfClass <<
" trying initial TrigTSerializer" );
529 pbuf =
new char[bufsiz];
531 const size_t nints = bufsiz/4;
532 for (
size_t i=pBuffOffset;
i<nints+pBuffOffset;
i++){
534 char *pch = (
char *)&pbytes;
535 for (
size_t c=0;
c<4;
c++){
536 pbuf[bufpos] = *(
char *)(pch+3-
c);
541 for (
size_t i=nints+pBuffOffset;
i<vsize;
i++){
542 pbuf[bufpos] = (
char)
v.at(
i);
548 for (
size_t i=0;
i<
v.size();
i++){
554 }
else if (!newFormatOK && decodeOldFormat){
556 pbuf =
new char[bufsiz];
558 for (
size_t i=0;
i<bufsiz;
i++)
571 TBufferFile *
buff =
new TBufferFile(TBuffer::kRead, bufsiz, pbuf, kTRUE);
574 TClass *pclass = gROOT->GetClass(noc.c_str());
576 TObject *pobj = NULL;
582 pobj = (TObject *)(ROOT8367Workaround::TBufferFileWorkaround::doReadObjectAny (
buff, pclass));
590 ATH_MSG_ERROR(
"gROOT->GetClass failed for" << nameOfClass );
602 TClass *pclass = gROOT->GetClass(nameOfClass.c_str());
608 sc = StatusCode::SUCCESS;
630 return StatusCode::SUCCESS;
634 return StatusCode::FAILURE;
638 for (
size_t i=0;
i<4;
i++)
647 <<
"ERROR! method TrigTSerializer::" << __PRETTY_FUNCTION__
648 <<
" was removed during migration to ROOT6" << endl;
662 const std::string classname =
name.substr(0,
name.find_last_of(
'*'));
664 do_persistify(classname,
ptr);