i’m tring to prepare an interface for FORTRAN an so i need to be able to read leaves.
I don’t understand why in the following code doesn’t give me back a value for “GetValue(##)” but always 0.
My leaf inherits from TLeafElement, the variable tree has been setted before as a general variable so it’s not null, also because all other GetNdata(), GetType(), etc… give me back correct values
double getleafdata_(int *Nentry, int *index, char leafName, int leafName_len){
leaf = (TLeaf)tree->GetLeaf(leafName);
double tempD;
if(tree != 0) tree->GetEntry((Int_t)*Nentry);
if (leaf->InheritsFrom(“TLeafElement”)){
TLeafElement tle = (TLeafElement)tree->GetLeaf(leafName);
tempD = (double)tle->GetValue(*index);
printf(“%d”, tempD);
}
printf(“leafNAme------>%s \n”, leafName);
printf(“Nentry------>%d \n”, *Nentry);
printf(“index------->%d \n”, *index);
printf(“Ndata------->%d \n”, leaf->GetNdata());
printf(“value------->%s \n”, leaf->GetValue(*index)); <-----this one get null in return
leaf->PrintValue(1); <---- this one print the correct value on stdout
as you can see GetValue is still zero… [/quote]
And this is normal. The ranger of the data is from 0 to Ndata exclusive.
I.e. You have to transform fortran index (1 to Ndata inclusive) to C index (0 to Ndata exclusive).
This is quite odd
I am unable to reproduce any problem.
In addition the code execute by PrintValue and GetValue is extremely similar (i.e. I don’t see the difference in you case).
Are you using a MakeClass generated skeleton?
Can you send me a tar file I can use to reproduce your problem?
The index has to be a C++ index AND you have properly use the value.
Your code reads:
this interpretes the argument to print a unsigned int. Since the argument is a double, it does not work right.
Once I use:
And set index to 0, and change the return value getleafdata to
I get the ouput below (which seems correct).
Cheers,
Philippe.
bash-2.05a$ ./edai
Hello, world.
Warning in TClass::TClass: no dictionary for class pamela::AlgorithmInfo is available
Warning in TClass::TClass: no dictionary for class pamela::RunInfo is available
Warning in TClass::TClass: no dictionary for class pamela::SubPacket is available
Warning in TClass::TClass: no dictionary for class pamela::TmtcEvent is available
Warning in TClass::TClass: no dictionary for class pamela::TmtcRecord is available
Records 3.
Event
fUniqueID
fBits
Tmtc_crc_ok
Records
Records.fUniqueID
Records.fBits
Records.TM_RECORD_OBT
Records.TM_DEA_ANA[16]
Records.TM_TH_ANA[16]
Records.TM_BIL_DIAG_ACQ[8]
Records.TM_CC_DIAG_ACQ[32]
Records.TM_DBL_ACQ[8]
Records.TM_DS_16_ACQ[2]
Records.TM_RECORD_CRC
Records.tmtc_crc_tot_ok
Records.TM_DEA_ANA_P[16]
Records.TM_TH_ANA_P[16]
leafName------>Records.TM_RECORD_OBT
Nentry------>0
index------->0
Ndata------->1
value------->9243.000000
Records.TM_RECORD_OBT = 9243
Records.TM_RECORD_OBT
0 0 9243