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));
 
   83   void* ReadObjectAnyNV (
const TClass*);
 
   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); 
 
  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 );
 
  237   declareProperty(
"OnlineMode", m_onlineMode=
false, 
"avoid initializations not needed in the online");
 
  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();
 
  328                      << 
" checksum: " << 
inf->GetCheckSum()  );
 
  335                        const char* location, 
const char *
msg){
 
  336    if( 
level > kInfo ) {
 
  344    ::DefaultErrorHandler(
level,abort_bool, location, 
msg);
 
  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);
 
  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);
 
  461       for (
size_t i=0; 
i<serialized.size(); 
i++){
 
  468     ATH_MSG_ERROR( 
"gROOT->GetClass failed for" << nameOfClass  );
 
  479   size_t rootDebug = gDebug;
 
  490   const size_t vsize = 
v.size();
 
  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);
 
  560       for (
size_t i=0; 
i<
v.size(); 
i++){
 
  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());
 
  620     sc = StatusCode::SUCCESS;
 
  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;
 
  674     const std::string classname = 
name.substr(0, 
name.find_last_of(
'*'));
 
  676     do_persistify(classname, 
ptr);