ROOT logo
// @(#)root/hbook:$Id$
// Author: Rene Brun   18/02/2002

/*************************************************************************
 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// THbookTree                                                           //
//                                                                      //
// A wrapper class supporting Hbook ntuples (CWN and RWN).              //
// The normal TTree calls can be used, including TTree::Draw().         //
// Data read directly from the Hbook file via THbookFile.               //
//                                                                      //
// IMPORTANT NOTE                                                       //
// When setting the branch address (via THbookTree::SetBranchAddress)   //
// for a branch in an Hbook block containing several names, eg          //
//    Hbook block SELEVN with the following variables:                  //
// ******************************************************************   //
//  *      1   * R*4  *         *              * SELEVN   * WGGS        //
//  *      2   * R*4  *         *              * SELEVN   * AM12        //
//  *      3   * R*4  *         *              * SELEVN   * AM34        //
//  *      4   * R*4  *         *              * SELEVN   * AM14        //
//  *      5   * R*4  *         *              * SELEVN   * AM32        //
//  *      6   * R*4  *         *              * SELEVN   * PtPI(4)     //
//  *      7   * R*4  *         *              * SELEVN   * PHIPI(4)    //
//  *      8   * R*4  *         *              * SELEVN   * THTPI(4)    //
// one must define a C struct like:                                     //
//   struct {                                                           //
//      Float_t Wggs;                                                   //
//      Float_t Am12;                                                   //
//      Float_t Am34;                                                   //
//      Float_t Am14;                                                   //
//      Float_t Am32;                                                   //
//      Float_t Ptpi[4];                                                //
//      Float_t Phipi[4];                                               //
//      Float_t Thtpi[4];                                               //
//   } event;                                                           //
//                                                                      //
// and set ONLY the first variable address with:                        //
//    h96->SetBranchAddress("Wggs",&event.Wggs);                        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "THbookTree.h"
#include "THbookBranch.h"
#include "TTreeFormula.h"


ClassImp(THbookTree)

//______________________________________________________________________________
THbookTree::THbookTree(): TTree()
{
   //default constructor
   fID   = 0;
   fType = 0;
   fX    = 0;
   fFile = 0;
   fInit = kFALSE;
}

//______________________________________________________________________________
THbookTree::THbookTree(const char *name,Int_t id)
    :TTree(name,name)
{
   //constructor
   fID   = id;
   fType = 0;
   fX    = 0;
   fFile = 0;
   fInit = kFALSE;
}


//______________________________________________________________________________
THbookTree::~THbookTree()
{
   //destructor
   if (fX) delete [] fX;
   if (fFile) fFile->DeleteID(fID);
}


//______________________________________________________________________________
Int_t THbookTree::GetEntry(Long64_t entry, Int_t /*getall*/)
{
   //get one entry from the hbook ntuple
   fReadEntry = entry;
   return fFile->GetEntry(entry,fID,fType,GetX());
}


//______________________________________________________________________________
void THbookTree::InitBranches(Long64_t entry)
{
   //Initialize the branch addresses
   Int_t nfill = GetPlayer()->GetNfill();
   if (nfill > 0) {fInit = kFALSE; return;}
   if (fInit) return;
   fInit = kTRUE;
   if (!GetPlayer()->GetVar1()) {
      GetEntry(entry);
      return;
   }
   //fFile->InitLeaves(fID, 5,GetPlayer()->GetMultiplicity());
   fFile->InitLeaves(fID, 0,GetPlayer()->GetSelect());
   fFile->InitLeaves(fID, 3,GetPlayer()->GetVar3());
   fFile->InitLeaves(fID, 2,GetPlayer()->GetVar2());
   fFile->InitLeaves(fID, 1,GetPlayer()->GetVar1());
}

//______________________________________________________________________________
void THbookTree::Print(Option_t *option) const
{
   //Print an overview of the hbook ntuple
   TTree::Print(option);
}

//______________________________________________________________________________
Long64_t THbookTree::SetEntries(Long64_t n)
{
   //Set the number of entries in the tree header and its branches
   fEntries = n;
   TIter next(GetListOfBranches());
   THbookBranch *branch;
   while ((branch=(THbookBranch*)next())) {
      branch->SetEntries(n);
   }
   return n;
}
 THbookTree.cxx:1
 THbookTree.cxx:2
 THbookTree.cxx:3
 THbookTree.cxx:4
 THbookTree.cxx:5
 THbookTree.cxx:6
 THbookTree.cxx:7
 THbookTree.cxx:8
 THbookTree.cxx:9
 THbookTree.cxx:10
 THbookTree.cxx:11
 THbookTree.cxx:12
 THbookTree.cxx:13
 THbookTree.cxx:14
 THbookTree.cxx:15
 THbookTree.cxx:16
 THbookTree.cxx:17
 THbookTree.cxx:18
 THbookTree.cxx:19
 THbookTree.cxx:20
 THbookTree.cxx:21
 THbookTree.cxx:22
 THbookTree.cxx:23
 THbookTree.cxx:24
 THbookTree.cxx:25
 THbookTree.cxx:26
 THbookTree.cxx:27
 THbookTree.cxx:28
 THbookTree.cxx:29
 THbookTree.cxx:30
 THbookTree.cxx:31
 THbookTree.cxx:32
 THbookTree.cxx:33
 THbookTree.cxx:34
 THbookTree.cxx:35
 THbookTree.cxx:36
 THbookTree.cxx:37
 THbookTree.cxx:38
 THbookTree.cxx:39
 THbookTree.cxx:40
 THbookTree.cxx:41
 THbookTree.cxx:42
 THbookTree.cxx:43
 THbookTree.cxx:44
 THbookTree.cxx:45
 THbookTree.cxx:46
 THbookTree.cxx:47
 THbookTree.cxx:48
 THbookTree.cxx:49
 THbookTree.cxx:50
 THbookTree.cxx:51
 THbookTree.cxx:52
 THbookTree.cxx:53
 THbookTree.cxx:54
 THbookTree.cxx:55
 THbookTree.cxx:56
 THbookTree.cxx:57
 THbookTree.cxx:58
 THbookTree.cxx:59
 THbookTree.cxx:60
 THbookTree.cxx:61
 THbookTree.cxx:62
 THbookTree.cxx:63
 THbookTree.cxx:64
 THbookTree.cxx:65
 THbookTree.cxx:66
 THbookTree.cxx:67
 THbookTree.cxx:68
 THbookTree.cxx:69
 THbookTree.cxx:70
 THbookTree.cxx:71
 THbookTree.cxx:72
 THbookTree.cxx:73
 THbookTree.cxx:74
 THbookTree.cxx:75
 THbookTree.cxx:76
 THbookTree.cxx:77
 THbookTree.cxx:78
 THbookTree.cxx:79
 THbookTree.cxx:80
 THbookTree.cxx:81
 THbookTree.cxx:82
 THbookTree.cxx:83
 THbookTree.cxx:84
 THbookTree.cxx:85
 THbookTree.cxx:86
 THbookTree.cxx:87
 THbookTree.cxx:88
 THbookTree.cxx:89
 THbookTree.cxx:90
 THbookTree.cxx:91
 THbookTree.cxx:92
 THbookTree.cxx:93
 THbookTree.cxx:94
 THbookTree.cxx:95
 THbookTree.cxx:96
 THbookTree.cxx:97
 THbookTree.cxx:98
 THbookTree.cxx:99
 THbookTree.cxx:100
 THbookTree.cxx:101
 THbookTree.cxx:102
 THbookTree.cxx:103
 THbookTree.cxx:104
 THbookTree.cxx:105
 THbookTree.cxx:106
 THbookTree.cxx:107
 THbookTree.cxx:108
 THbookTree.cxx:109
 THbookTree.cxx:110
 THbookTree.cxx:111
 THbookTree.cxx:112
 THbookTree.cxx:113
 THbookTree.cxx:114
 THbookTree.cxx:115
 THbookTree.cxx:116
 THbookTree.cxx:117
 THbookTree.cxx:118
 THbookTree.cxx:119
 THbookTree.cxx:120
 THbookTree.cxx:121
 THbookTree.cxx:122
 THbookTree.cxx:123
 THbookTree.cxx:124
 THbookTree.cxx:125
 THbookTree.cxx:126
 THbookTree.cxx:127
 THbookTree.cxx:128
 THbookTree.cxx:129
 THbookTree.cxx:130
 THbookTree.cxx:131
 THbookTree.cxx:132
 THbookTree.cxx:133
 THbookTree.cxx:134
 THbookTree.cxx:135
 THbookTree.cxx:136