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
101
102
103////////////////////////////////////////////////////////////////////////////////
104///Initialize the branch addresses
105
107{
109 if (nfill > 0) {fInit = kFALSE; return;}
110 if (fInit) return;
111 fInit = kTRUE;
112 if (!GetPlayer()->GetVar1()) {
114 return;
115 }
116 //fFile->InitLeaves(fID, 5,GetPlayer()->GetMultiplicity());
121}
122
123////////////////////////////////////////////////////////////////////////////////
124///Print an overview of the hbook ntuple
125
130
131////////////////////////////////////////////////////////////////////////////////
132///Set the number of entries in the tree header and its branches
133
135{
136 fEntries = n;
137 TIter next(GetListOfBranches());
139 while ((branch=(THbookBranch*)next())) {
140 branch->SetEntries(n);
141 }
142 return n;
143}
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
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 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.
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:89
TTreeFormula * GetSelect()
Definition TTree.h:591
TVirtualTreePlayer * GetPlayer()
Load the TTreePlayer (if not already done).
Definition TTree.cxx:6386
void Print(Option_t *option="") const override
Print a summary of the tree contents.
Definition TTree.cxx:7376
Long64_t fEntries
Number of entries.
Definition TTree.h:94
TTreeFormula * GetVar2()
Definition TTree.h:607
virtual TObjArray * GetListOfBranches()
Definition TTree.h:567
TTreeFormula * GetVar3()
Definition TTree.h:609
Long64_t fReadEntry
! Number of the entry being processed
Definition TTree.h:117
TTreeFormula * GetVar1()
Definition TTree.h:605
virtual Int_t GetNfill() const =0
const Int_t n
Definition legend1.C:16