Read rules for TComplex members

Hi,

suppose I have a class

class Data {
    public:
        unsigned int          entry;
        TComplex             value;
        std::vector<TComplex> values;
        
    ClassDef(Data, 1)
};

that has been stored in a TTree. I now want to update this class to contain additional members that can be calculated from the current members

class Data {
    public:
        unsigned int          entry;
        unsigned int          twoTimesEntry;
        TComplex             value;
        double               normOfValue;
        std::vector<TComplex> values;
        double               normOfSum;

    ClassDef(Data, 2)
};

My naive expectation would be, that I can achieve this by using the following read rules

#pragma read sourceClass="Data" version="[1]" targetClass="Data" \
             source="unsigned int entry" target="twoTimesEntry" \
             code="{ twoTimesEntry = 2 * onfile.entry; }"
#pragma read sourceClass="Data" version="[1]" targetClass="Data" \
             source="TComplex value" target="normOfValue" \
             code="{ normOfValue = onfile.value.Rho2(); }"
#pragma read sourceClass="Data" version="[1]" targetClass="Data" \
             source="std::vector<TComplex> values" target="normOfSum" \
             code="{ TComplex sum; for (size_t i=0; i<onfile.values.size(); ++i) sum += onfile.values[i]; normOfSum = sum.Rho2(); }"

While the read rule to calculate twoTimesEntry is working, both rules using the TComplex member variables do not work. I attached two simple scripts writing a tree with the old class version, and trying to read the tree back using the new version of the class. Can anyone spot whether I am making a mistake here, or is this something that is not expected to be working.
read.C (1.65 KB)
write.C (694 Bytes)

Which version of ROOT are you using?

Philippe.

I tried with 6.04.02, 6.06.04, and git HEAD, all with the same result.

Sebastian

Hi Philippe,

do you have any idea what might be wrong here?

Sebastian