Obtaining class version of objects read in from a TTree


I am dealing with ntuples that contain a shower object that has changed a bit over time. The newer versions of the object contain additional data-members corresponding to a more sophisticated energy reconstruction. While running with a version of the code associated with the newer version of my shower object, I’d like to detect if the actual object read in from disk is from an older version so I can take different action. This is what I’ve tried, perhaps it will be more clear:

  Version_t ver = ntpShower->Class()->GetClassVersion();
  if(ver <=7){
  else {

ntpShower is a pointer to my shower object. The code above doesn’t work, the variable “ver” always corresponds to the newer class version. That is, the version associated with the code in memory rather than the obect stored in the ntuple. Is it possible to successfully test for the class version of objects on disk? I’m afraid I’ve wandered into an area of ROOT that I know very little about.

Mike Kordosky

Hi Mike,

Implement a custom Streamer for your class. See examplse in ROOT itself, eg TAxis::Streamer.
See Users Guide for creating a custom Streamer.