Re: [ROOT] Streamer problem: inconsistancy between stand-alone write vs. interactive read...

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Dec 13 2002 - 20:09:44 MET


Hi Ed,

Instead of :
 rootcint -f headerdict.cpp -c CLasHeader.h
do
rootcint -f headerdict.cpp -c CLasHeader.h myLinkDef.h

with 
//file myLinkDef.h
#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class CLasHeader+;

#endif

see Users Guide

Rene

On Fri, 13 Dec 2002, Ed Oltman wrote:

> Hello,
>  I am using root 3.03/9a on win2k.  I have a stand-alone project that
> includes the class CLasHeader shown below.  When I build the project, I use
> 
> rootcint -f headerdict.cpp -c CLasHeader.h
> 
> and I include the resulting headerdict.cpp and headerdict.h in my project
> build (VC++6).  In the standalong file, I do:
> 
>  TFile *f = new TFile("stream.root","recreate");
>  CLasHeader h;
>  	...
>  h->Write()
> 
> Now, in an interactive root session, I do the following:
> 
> root [0] TFile *f = new TFile("stream.root")
> root [1] .L CLasHeader.cpp++
> Info in <TWinNTSystem::ACLiC>: creating shared library
> C:\str\CLasHeader_cpp.dll
> 1678.cxx
> 1680.cxx
> 1682.cxx
> 1684.cxx
> svo_.cxx
>    Creating library CLasHeader_cpp.lib and object CLasHeader_cpp.exp
> root [2] CLasHeader *ph = (CLasHeader *)f->Get("CLasHeader")
> Error in <TBuffer::CheckByteCount>: object of class CLasHeader read too few
> bytes: 192 instead of 196
> Warning in <TBuffer::CheckByteCount>: CLasHeader::Streamer() not in sync
> with data on file, fix Streamer()
> 
> Note: If I remove the  Double_t fApertureAtten[8] from the class, the
> streamer works fine.  It looks like a bug...
> 
> Ed Oltman
> 
> 
> 
> 
> 
> 
> 
> 
> #ifndef _CLASHEADER_H_
> #define _CLASHEADER_H_
> #include "TObject.h"
> class CLasHeader : public TObject
> {
> public:
>     CLasHeader();
>     ~CLasHeader();
>     void Fill(char *pFromLas);
>     UInt_t fHeaderSize;					//Las header size in bytes
>     UInt_t fStreamVersion;				//Stream version number
>     UInt_t fAcquisitionVersion;			//Acquisition version number
>     UInt_t fHardwareConfiguration;			//Hardware configuration
>     UInt_t fRunNumber;					//Run number
>     UInt_t fAtomProbeId;				//Atom probe ID
>     UInt_t fDebugFlag;					//Debug flag
>     UInt_t fAcquisitionMode;				//Acquisition mode
>     UInt_t fStartDate;					//Start date in form YYYYMMDD  e.g. 20021213
>     UInt_t fStartTime;					//Start time in form HHMMSS  e.g. 153214
>     UInt_t fMaxHitsPerPulse;				//Maximum number of hits per pulse
>     Double_t fDeltaTofCorrection;			//(TOF_X-TOF_Y)/(-2) in nsec
>     Double_t fNsPerLsb;					//TDC least significant bit in nsec
>     Double_t fT0Estimate;				//Estimate of T0 in nsec
>     Double_t fXposOffset;				//Estimate of detector's x-position in ns
>     Double_t fYposOffset;				//Estimate of detector's y-position in ns
>     Double_t fUnAttenApVoltage;			//Unattenuated aperture voltage
>     Double_t fApertureAtten[8];			//Array of aperture attenuation values
>     Double_t fTargetEvapRate;				//Initial target evaporation rate in
> percent
>     Double_t fTargetPulseFraction;			//Initial target pulse fraction in
> percent
>     Double_t fInitialPulseFreq;			//Initial target pulse frequency in Hz
> #if !defined(__CINT__)  || defined(__MAKECINT__)
> 	ClassDef(CLasHeader,1)
> #endif
> };
> #endif
> 
> 
> Here is the rootcint generated streamer:
> 
> //__________________________________________________________________________
> ____
> void CLasHeader::Streamer(TBuffer &R__b)
> {
>    // Stream an object of class CLasHeader.
> 
>    UInt_t R__s, R__c;
>    if (R__b.IsReading()) {
>       Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
>       TObject::Streamer(R__b);
>       R__b >> fHeaderSize;
>       R__b >> fStreamVersion;
>       R__b >> fAcquisitionVersion;
>       R__b >> fHardwareConfiguration;
>       R__b >> fRunNumber;
>       R__b >> fAtomProbeId;
>       R__b >> fDebugFlag;
>       R__b >> fAcquisitionMode;
>       R__b >> fStartDate;
>       R__b >> fStartTime;
>       R__b >> fMaxHitsPerPulse;
>       R__b >> fDeltaTofCorrection;
>       R__b >> fNsPerLsb;
>       R__b >> fT0Estimate;
>       R__b >> fXposOffset;
>       R__b >> fYposOffset;
>       R__b >> fUnAttenApVoltage;
>       R__b.ReadStaticArray(fApertureAtten);
>       R__b >> fTargetEvapRate;
>       R__b >> fTargetPulseFraction;
>       R__b >> fInitialPulseFreq;
>       R__b.CheckByteCount(R__s, R__c, CLasHeader::IsA());
>    } else {
>       R__c = R__b.WriteVersion(CLasHeader::IsA(), kTRUE);
>       TObject::Streamer(R__b);
>       R__b << fHeaderSize;
>       R__b << fStreamVersion;
>       R__b << fAcquisitionVersion;
>       R__b << fHardwareConfiguration;
>       R__b << fRunNumber;
>       R__b << fAtomProbeId;
>       R__b << fDebugFlag;
>       R__b << fAcquisitionMode;
>       R__b << fStartDate;
>       R__b << fStartTime;
>       R__b << fMaxHitsPerPulse;
>       R__b << fDeltaTofCorrection;
>       R__b << fNsPerLsb;
>       R__b << fT0Estimate;
>       R__b << fXposOffset;
>       R__b << fYposOffset;
>       R__b << fUnAttenApVoltage;
>       R__b.WriteArray(fApertureAtten, 8);
>       R__b << fTargetEvapRate;
>       R__b << fTargetPulseFraction;
>       R__b << fInitialPulseFreq;
>       R__b.SetByteCount(R__c, kTRUE);
>    }
> }
> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:23 MET