[ROOT] Re: [orca-developers] Trouble in saving to Tree from ORCA

From: Andrea 'fwyzard' Bocci (Andrea.Bocci@cern.ch)
Date: Sun Jul 11 2004 - 19:04:31 MEST


Hi Mario,
the problem is in your constructor:

> (in constructor)
>   myFile = new TFile(filename,"RECREATE");
>   myTree = new TTree("T1","ORCA tutorial tree");
>   myNumberOfTowers=0;
>
>   myTree->Branch("Ntowers",  &myNumberOfTowers, "Ntowers/I");
>   myTree->Branch("Etower",   &myETw,            "Etower[Ntowers]/F");
>   myTree->Branch("Phitower", &myPhiTw,          "Phitower[Ntowers]/F");
>   myTree->Branch("Etatower", &myEtaTw,          "Etatower[Ntowers]/F");
>
>   myMuonNr=0;
>
>   myTree->Branch("MuonNr",      &myMuonNr,      "MuonNr/I");
>   myTree->Branch("Px",          &myPx,          "Px/F");
>   myTree->Branch("Py",          &myPy,          "Py/F");
>   myTree->Branch("Pz",          &myPz,          "Pz/F");
>   myTree->Branch("P",           &myP,           "P/F");
>   myTree->Branch("N",           &myN,           "N/I");
>
Here you say to ROOT two quite different things about Towers and Muons:
 - Tower data are declared as arrays of floats with Ntowers elements 
("Etower[Ntowers]/F" means this);
 - Muon data are declared as simple float values ("Px/F").
The correct declaration for the Muon data should be

  myTree->Branch("MuonNr",      &myMuonNr,      "MuonNr/I");
  myTree->Branch("Px",          &myPx,          "Px[MuonNr]/F");
  myTree->Branch("Py",          &myPy,          "Py[MuonNr]/F");
  myTree->Branch("Pz",          &myPz,          "Pz[MuonNr]/F");
  myTree->Branch("P",           &myP,           "P[MuonNr]/F");
  myTree->Branch("N",           &myN,           "N[MuonNr]/I");

which declares everything as arrays of float with MuonNr elements.

Cheers,
.Andrea.

-- 

Andrea 'fwyzard' Bocci - Andrea.Bocci@cern.ch
UniversitÓ di Firenze - Dipartimento di Fisica



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