Root behaves weirdly, confuses one leaf for the other!

Hi Rooters,

I have a bizarre problem where root confuses one leaf for the other, let me explain in details. The structure of my file looks like this:


******************************************************************************
*Tree    :Board     : MonitoringBoard                                        *
*Entries : 13417545 : Total =      5155079632 bytes  File  Size =  487469956 *
*        :          : Tree compression factor =  10.58                       *
******************************************************************************
*Br    0 :pin1      : cNBOF/L:NBOF/L:t_BOF/L:t_year/I:t_mon/I:t_day/I:       *
*         | t_secday/I:cspTemp/I:extTemp/I:boardTemp/I:Vbias1/I:Vbias2/I:    *
*         | amplitude/I:baseline/I:ADCVal/I:bAddr/I:totW/I:Width/I                    *
*Entries : 13417545 : Total  Size= 1288762396 bytes  File Size  =  125576669 *
*Baskets :     7349 : Basket Size=    3764224 bytes  Compression=  10.26     *
*............................................................................*
*Br    1 :pin2      : cNBOF/L:NBOF/L:t_BOF/L:t_year/I:t_mon/I:t_day/I:       *
*         | t_secday/I:cspTemp/I:extTemp/I:boardTemp/I:Vbias1/I:Vbias2/I:    *
*         | amplitude/I:baseline/I:ADCVal/I:bAddr/I:totW/I:Width/I                    *
*Entries : 13417545 : Total  Size= 1288762396 bytes  File Size  =  130796781 *
*Baskets :     7349 : Basket Size=    3764224 bytes  Compression=   9.85     *
*............................................................................*

Where the leaf “bAddr” contains six numbers 1, 2, ..., 6 and ADCVal contains some values around 7000, I am not going to describe all the variables but this will suffice to explain my problem.

When I plot using Board->Draw("pin1.bAddr") or Board->Draw("pin2.ADCVal") I see what I expect but when I use MakeClass() that generates let’s say Board.h and Board.C, where Board.h contains the following:

   Long64_t        pin1_cNBOF;
   Long64_t        pin1_NBOF;
   Long64_t        pin1_t_BOF;
   Int_t           pin1_t_year;
   Int_t           pin1_t_mon;
   Int_t           pin1_t_day;
   Int_t           pin1_t_secday;
   Int_t           pin1_cspTemp;
   Int_t           pin1_extTemp;
   Int_t           pin1_boardTemp;
   Int_t           pin1_Vbias1;
   Int_t           pin1_Vbias2;
   Int_t           pin1_amplitude;
   Int_t           pin1_baseline;
   Int_t           pin1_ADCVal;
   Int_t           pin1_bAddr;
   Int_t           pin1_totW;
   Int_t           pin1_Width;
   Long64_t        pin2_cNBOF;
   Long64_t        pin2_NBOF;
   Long64_t        pin2_t_BOF;
   Int_t           pin2_t_year;
   Int_t           pin2_t_mon;
   ...

etc.

If I use this class method and call the variable pin1_bAddr what I get is strange, it’s around 7000 that looks exactly like ADCVal. Same is true for all other variables, that is they all are jumbled up! Why is that so? How can I fix this?

Thanks a lot


_ROOT Version: 5.27/02
_Platform: Scientific Linux SL release 5.4 (Boron)
_Compiler: g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50)


Can you create an example to reproduce the problem?

My best guess so far is that you have reordered the variables. Do you have a more complete code example?

I would recommend to create a struct that resembles your multi-leaf branch:

struct PinData {
    // do not reorder variables
    Long64_t nNBOF;
    Long64_t NBOF;
    Long64_t t_NBOF;
    Int_t t_year;
    (...)
    Int_t Width;
  
    PinData(TTree* tree, const char *name) { 
        tree->SetBranchAddress(name, &nNBOF);
    }
};

int main() {
    ...
    PinData pin1(tree, "pin1");
    PinData pin2(tree, "pin2");
    tree->GetEntry(...);
    std::cout << pin1.bAddr << '\n';
    ...
}

In addition: why still ROOT 5.27 and SL 5.4? That is ancient software!

Hi behrenhoff, thanks a lot. Your guess is right, turns out that I had another “Long64_t” after an “Int_t”. Creating a root file with right order solved the problem.

Yes that root is ancient :rofl: I know, unfortunately it’s an ancient computer too and I have no root (su) access.

Thanks very much

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.