Custom operations after reading in object from buffer

Hi,

I have a class X deriving from TObject with the dictionary information generated and compiled into a shared library. The class contains an array of type TObjArray. When I read class X from a buffer (file) I need to perform some custom operations on the objects stored in the array. I need these to be performed transparently so that a user does not need to call any extra methods or special read methods. I tried to customise the streamer for my class X, but the problem I noticed was that after the call to ReadClassBuffer, the array is still empty. It looks like the array itself is read in by some other streamer and the objects added to the array later.
Does anyone have any advice about where to place these custom operations if not in the streamer?
If the streamer is the right location, then why is the array empty after a call to ReadClassBuffer, even if the object definitely has objects added to the array before being written to the buffer?

Thanks.

[quote] I tried to customise the streamer for my class X, but the problem I noticed was that after the call to ReadClassBuffer, the array is still empty. [/quote]If the array is a datamember of class X, it is filled during the execution of the Streamer for class X (i.e. in ReadClassBuffer).

Customizing the Streamer is one possibly way of doing what you need however Streamer are not called for objects that are split (in a TTree). For those cases, you will need v5.26 and use an I/O customization rule.

Cheers,
Philippe.

Thank you for the reply. After further investigation into my code I figured out that I was misunderstanding exactly what was going on.
Indeed, as you say, the streamer is not called when written to a TTree with split-mode > 0 and that is why I was seeing the symptoms. So I need to know how to force the streamer to be used even if split-mode was > 0. I tried the “//||” option for the data members with no success.
Could you please tell me more about the “I/O customization rule” or indicate where I can find out more about this feature. I presume this mechanism will allow me to force the streamer to be used.
Thank you.

Hi,

[quote]I tried the “//||” option for the data members with no success. [/quote]This should indeed prevent the split of just this data member (and of course does not say anything about the class that contains this data member).

When you create a branch you can prevent the splitting of the whole branch was selecting a split level of 0:tree->Branch(branchname,&pointer_to_object,32000,0); // buffer size of 32000 bytes

You can see a description of the I/O customization rules at indico.cern.ch/contributionDispl … nfId=35523

A simple example using ACLiC is:[code]

class MyClass {
public:
int a;
float b; //!
double c;
ClassDef(MyClass,1);
};

#ifdef MAKECINT
#pragma read sourceClass=“MyClass” targetClass=“MyClass”
source="" target=“b”
version=[1-] code="{ b = newObj->a; }"
#endif[/code]

Cheers,
Philippe.