[ROOT] Problems reading root files - reading rubbish

From: Torsten Harenberg (harenberg@physik.uni-wuppertal.de)
Date: Thu Feb 05 2004 - 12:30:52 MET


Dear all,

I'm facing a major problem reading back data from root files.

I created a skeleton using the MakeClass Method. Deriving from this, I use
a simple code like:

#define muonana2_cxx
#include "muonana2.h"
#include "TH2.h"
#include "TF1.h"
#include "TStyle.h"
#include "TCanvas.h"
#include "TMath.h"
#include "TGraphErrors.h"
#include <iostream>

using namespace std;

void muonana2::Loop()
{
  if (fChain == 0) return;
  Int_t nentries = Int_t(fChain->GetEntriesFast());

  Int_t nbytes = 0, nb = 0;
  for (Int_t jentry=0; jentry<10;jentry++) {
    Int_t ientry = LoadTree(jentry);
    if (ientry < 0) break;

    b_event_ntrack->GetEntry(ientry);
    b_frecTracks_id->GetEntry(ientry);
    b_frecTracks_e->GetEntry(ientry);
    b_frecTracks_costh->GetEntry(ientry);
    b_frecTracks_phi->GetEntry(ientry);
    b_fgenTracks_id->GetEntry(ientry);
    b_fgenTracks_costh->GetEntry(ientry);
    b_fgenTracks_phi->GetEntry(ientry);
    b_fgenTracks_e->GetEntry(ientry);

    cout << "phi: " << frecTracks_phi[1] << "   cos(theta): " <<
frecTracks_costh[1] << endl;

  }
}


Which gives the following results:

phi: 0.725436   cos(theta): 0.865058
phi: 1.97669   cos(theta): 2.01212
phi: 1.95156   cos(theta): 1.68802
phi: 1.94538   cos(theta): 1.95107
phi: 1.66711   cos(theta): 1.64055
phi: 1.94412   cos(theta): 1.94372
phi: 1.96575   cos(theta): 2.11176
phi: 0.405632   cos(theta): 0.404347
phi: 0.517295   cos(theta): 0.571443
phi: 0.480233   cos(theta): 0.318776

phi looks ok, but fgenTracks_costh[1] seems to be rubbish:

root [4] T->Scan("frecTracks.costh[1]","","",10,0);
************************
*    Row   * frecTrack *
************************
*        0 * 0.3106747 *
*        1 * 0.9214717 *
*        2 * 0.9433813 *
*        3 * 0.9216736 *
*        4 * 0.9338010 *
*        5 * 0.9204052 *
*        6 * 0.9386273 *
*        7 * 0.6487550 *
*        8 * 0.6157632 *
*        9 * 0.6854105 *
************************

If I now change the position of the GetEntry() commands to for example:

    b_event_ntrack->GetEntry(ientry);
    b_frecTracks_id->GetEntry(ientry);
    b_frecTracks_e->GetEntry(ientry);
    b_frecTracks_phi->GetEntry(ientry);
    b_fgenTracks_id->GetEntry(ientry);
    b_fgenTracks_costh->GetEntry(ientry);
    b_fgenTracks_phi->GetEntry(ientry);
    b_fgenTracks_e->GetEntry(ientry);
    b_frecTracks_costh->GetEntry(ientry);

now frecTracks_costh is okay, but frecTracks_phi disagrees with a Scan.

I tried out the other version given in the MakeClass code
(fChain->SetBranchStatus("variable",1); and nb = fChain->GetEntry(jentry);
nbytes += nb;), but without any success (same problem).

Furthermore I tried on Linux (SuSE 8.1) running root 3.10/02 and on Mac OS
X running root 3.05/05 - the results are the same.

Now I'm really stuck. Has anybody any idea how to read back *ALL* data
correctly?

I put the root-file I used on

http://www.atlas.uni-wuppertal.de/~harenber/Event.root

Thanks a lot!!!

  Torsten

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<>                                                              <>
<> Torsten Harenberg         harenberg@physik.uni-wuppertal.de  <>
<> Bergische Universitaet                                       <>
<> FB C - Physik             Tel.: +49 (0)202 439-3521          <>
<> Gaussstr. 20              Fax : +49 (0)202 439-2811          <>
<> 42097 Wuppertal                                              <>
<>                                                              <>
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:05 MET