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
57
58////////////////////////////////////////////////////////////////////////////////
59///default constructor
60
62{
63 fID = 0;
64 fType = 0;
65 fX = nullptr;
66 fFile = nullptr;
67 fInit = kFALSE;
68}
69
70////////////////////////////////////////////////////////////////////////////////
71///constructor
72
75{
76 fID = id;
77 fType = 0;
78 fX = nullptr;
79 fFile = nullptr;
80 fInit = kFALSE;
81}
82
83
84////////////////////////////////////////////////////////////////////////////////
85///destructor
86
88{
89 if (fX) delete [] fX;
90 if (fFile) fFile->DeleteID(fID);
91}
92
93
94////////////////////////////////////////////////////////////////////////////////
95///get one entry from the hbook ntuple
96
98{
99 fReadEntry = entry;
100 return fFile->GetEntry(entry,fID,fType,GetX());
101}
102
103
104////////////////////////////////////////////////////////////////////////////////
105///Initialize the branch addresses
106
108{
109 Int_t nfill = GetPlayer()->GetNfill();
110 if (nfill > 0) {fInit = kFALSE; return;}
111 if (fInit) return;
112 fInit = kTRUE;
113 if (!GetPlayer()->GetVar1()) {
114 GetEntry(entry);
115 return;
116 }
117 //fFile->InitLeaves(fID, 5,GetPlayer()->GetMultiplicity());
122}
123
124////////////////////////////////////////////////////////////////////////////////
125///Print an overview of the hbook ntuple
126
128{
130}
131
132////////////////////////////////////////////////////////////////////////////////
133///Set the number of entries in the tree header and its branches
134
136{
137 fEntries = n;
138 TIter next(GetListOfBranches());
139 THbookBranch *branch;
140 while ((branch=(THbookBranch*)next())) {
141 branch->SetEntries(n);
142 }
143 return n;
144}
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
char name[80]
Definition TGX11.cxx:110
HBOOK Branch.
void SetEntries(Long64_t n) override
Set the number of entries in this branch.
void InitLeaves(Int_t id, Int_t var, TTreeFormula *formula)
This function is called from the first entry in TTreePlayer::InitLoop It analyzes the list of variabl...
void DeleteID(Int_t id)
remove id from file and memory
Int_t GetEntry(Int_t entry, Int_t id, Int_t atype, Float_t *x)
Read in memory all columns of entry number of ntuple id from the Hbook file.
A wrapper class supporting Hbook ntuples (CWN and RWN).
Definition THbookTree.h:30
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.
A TTree represents a columnar dataset.
Definition TTree.h:79
TTreeFormula * GetSelect()
Definition TTree.h:552
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition TTree.cxx:6295
void Print(Option_t *option="") const override
Print a summary of the tree contents.
Definition TTree.cxx:7209
Long64_t fEntries
Number of entries.
Definition TTree.h:84
TTreeFormula * GetVar2()
Definition TTree.h:568
virtual TObjArray * GetListOfBranches()
Definition TTree.h:528
TTreeFormula * GetVar3()
Definition TTree.h:570
Long64_t fReadEntry
! Number of the entry being processed
Definition TTree.h:107
TTreeFormula * GetVar1()
Definition TTree.h:566
virtual Int_t GetNfill() const =0
const Int_t n
Definition legend1.C:16