Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
THbookTree.cxx
Go to the documentation of this file.
1// @(#)root/hbook:$Id$
2// Author: Rene Brun 18/02/2002
3
4/*************************************************************************
5 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class THbookTree
13 \ingroup Hist
14 A wrapper class supporting Hbook ntuples (CWN and RWN).
15 The normal TTree calls can be used, including TTree::Draw().
16 Data read directly from the Hbook file via THbookFile.
17
18 IMPORTANT NOTE
19 When setting the branch address (via THbookTree::SetBranchAddress)
20 for a branch in an Hbook block containing several names, eg
21 Hbook block SELEVN with the following variables:
22
23~~~
24 ******************************************************************
25 * 1 * R*4 * * * SELEVN * WGGS
26 * 2 * R*4 * * * SELEVN * AM12
27 * 3 * R*4 * * * SELEVN * AM34
28 * 4 * R*4 * * * SELEVN * AM14
29 * 5 * R*4 * * * SELEVN * AM32
30 * 6 * R*4 * * * SELEVN * PtPI(4)
31 * 7 * R*4 * * * SELEVN * PHIPI(4)
32 * 8 * R*4 * * * SELEVN * THTPI(4)
33
34 one must define a C struct like:
35 struct {
36 Float_t Wggs;
37 Float_t Am12;
38 Float_t Am34;
39 Float_t Am14;
40 Float_t Am32;
41 Float_t Ptpi[4];
42 Float_t Phipi[4];
43 Float_t Thtpi[4];
44 } event;
45
46 and set ONLY the first variable address with:
47 h96->SetBranchAddress("Wggs",&event.Wggs);
48~~~
49*/
50
51#include "THbookTree.h"
52#include "THbookBranch.h"
53#include "TTreeFormula.h"
54
55
56
57////////////////////////////////////////////////////////////////////////////////
58///default constructor
59
61{
62 fID = 0;
63 fType = 0;
64 fX = nullptr;
65 fFile = nullptr;
66 fInit = kFALSE;
67}
68
69////////////////////////////////////////////////////////////////////////////////
70///constructor
71
74{
75 fID = id;
76 fType = 0;
77 fX = nullptr;
78 fFile = nullptr;
79 fInit = kFALSE;
80}
81
82
83////////////////////////////////////////////////////////////////////////////////
84///destructor
85
87{
88 if (fX) delete [] fX;
89 if (fFile) fFile->DeleteID(fID);
90}
91
92
93////////////////////////////////////////////////////////////////////////////////
94///get one entry from the hbook ntuple
95
97{
98 fReadEntry = entry;
99 return fFile->GetEntry(entry,fID,fType,GetX());
100}
101
102
103////////////////////////////////////////////////////////////////////////////////
104///Initialize the branch addresses
105
107{
108 Int_t nfill = GetPlayer()->GetNfill();
109 if (nfill > 0) {fInit = kFALSE; return;}
110 if (fInit) return;
111 fInit = kTRUE;
112 if (!GetPlayer()->GetVar1()) {
113 GetEntry(entry);
114 return;
115 }
116 //fFile->InitLeaves(fID, 5,GetPlayer()->GetMultiplicity());
117 fFile->InitLeaves(fID, 0,GetPlayer()->GetSelect());
118 fFile->InitLeaves(fID, 3,GetPlayer()->GetVar3());
119 fFile->InitLeaves(fID, 2,GetPlayer()->GetVar2());
120 fFile->InitLeaves(fID, 1,GetPlayer()->GetVar1());
121}
122
123////////////////////////////////////////////////////////////////////////////////
124///Print an overview of the hbook ntuple
125
126void THbookTree::Print(Option_t *option) const
127{
128 TTree::Print(option);
129}
130
131////////////////////////////////////////////////////////////////////////////////
132///Set the number of entries in the tree header and its branches
133
135{
136 fEntries = n;
137 TIter next(GetListOfBranches());
138 THbookBranch *branch;
139 while ((branch=(THbookBranch*)next())) {
140 branch->SetEntries(n);
141 }
142 return n;
143}
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
XFontStruct * id
Definition TGX11.cxx:147
char name[80]
Definition TGX11.cxx:148
HBOOK Branch.
void SetEntries(Long64_t n) override
Set the number of entries in this branch.
Float_t * GetX()
Definition THbookTree.h:47
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
get one entry from the hbook ntuple
Long64_t SetEntries(Long64_t n=-1) override
Set the number of entries in the tree header and its branches.
THbookTree()
default constructor
void Print(Option_t *option="") const override
Print an overview of the hbook ntuple.
Int_t fID
Definition THbookTree.h:33
THbookFile * fFile
Definition THbookTree.h:37
~THbookTree() override
destructor
Int_t fType
Definition THbookTree.h:34
Bool_t fInit
Definition THbookTree.h:36
char * fX
Definition THbookTree.h:35
virtual void InitBranches(Long64_t entry)
Initialize the branch addresses.
TTreeFormula * GetSelect()
Definition TTree.h:599
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition TTree.cxx:6416
void Print(Option_t *option="") const override
Print a summary of the tree contents.
Definition TTree.cxx:7414
Long64_t fEntries
Number of entries.
Definition TTree.h:94
TTreeFormula * GetVar2()
Definition TTree.h:615
TTree()
Default constructor and I/O constructor.
Definition TTree.cxx:764
virtual TObjArray * GetListOfBranches()
Definition TTree.h:575
TTreeFormula * GetVar3()
Definition TTree.h:617
Long64_t fReadEntry
! Number of the entry being processed
Definition TTree.h:117
TTreeFormula * GetVar1()
Definition TTree.h:613
virtual Int_t GetNfill() const =0
const Int_t n
Definition legend1.C:16