GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CorrelatedSpaceTree2I.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck *
3  * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef Gw_CorrelatedSpaceTree2I
24 #include "CorrelatedSpaceTree2I.h"
25 #endif
26 
27 #ifndef ROOT_TFile
28 #include "TFile.h"
29 #endif
30 
31 #ifndef ROOT_TH2
32 #include "TH2.h"
33 #endif
34 
35 #ifndef ROOT_TRandom
36 #include "TRandom.h"
37 #endif
38 
39 #ifndef ROOT_TTree
40 #include "TTree.h"
41 #endif
42 
43 using namespace Gw;
44 
45 //
47 
48 //__________________________________________________________
51  fCounts(0)
52 {
53  // default constructor
54  fLog.GetProcessName() = "CorrelatedSpaceTree2I";
55 }
56 
57 //__________________________________________________________
59 {
60  // default destructor
61 }
62 
63 //__________________________________________________________
65 {
66  fTree->Branch(fBranchName.Data(), &fCounts, "fCounts/I");
67 }
68 
69 //__________________________________________________________
71 {
72  TBranch* b = fTree->GetBranch(fBranchName.Data());
73  if (b == 0x0) {
74  fLog << warning << "Branch not find in tree" << dolog;
75  return 0x0;
76  }
77 
78  b->SetAddress(&fCounts);
79 
80  return b;
81 }
82 
83 //__________________________________________________________
84 void CorrelatedSpaceTree2I::SetCounts(Double_t weight)
85 {
86  fCounts = Int_t(weight+0.5);
87 }
88 
89 //__________________________________________________________
90 void CorrelatedSpaceTree2I::FillCounts(Int_t i, Int_t j, TH2* h2)
91 {
92  fCounts = (Int_t)(h2->GetBinContent(h2->GetBin(i,j)) + 0.5);
93  GetHistoTot("x")->Fill(j, fCounts);
94 }
95 
96 //__________________________________________________________
97 void CorrelatedSpaceTree2I::FillCounts(Int_t i, Int_t j, Int_t dimX, const Double_t* Xn, const Double_t weight)
98 {
99  fCounts = Int_t(Xn[i*dimX + j]*weight + 0.5);
100  GetHistoTot("x")->Fill(j, fCounts);
101 }
102 
103 //__________________________________________________________
105 {
106  fCounts = (Int_t)(gRandom->Uniform(0, 10)+0.5);
107  GetHistoTot("x")->Fill(j, fCounts);
108 }
109 
110 //__________________________________________________________
111 void CorrelatedSpaceTree2I::FillHisto(Int_t j, TH1* h1)
112 {
113  h1->Fill(j, fCounts);
114 }
115 
116 //__________________________________________________________
118 {
119 
120  if (fStatus == kDefined) {
121 
122  Int_t dimX = GetHistoTot("x")->GetNbinsX();
123  Int_t dimY = GetHistoTot("y")->GetNbinsX();
124 
125  if (fTree->GetEntries() == dimX*dimY) {
126 
127  for (Int_t i = 0; i < dimX; ++i) {
128  for (Int_t j = 0; j < dimY; ++j) {
129  fTree->GetEntry(i*dimX + j);
130  Double_t tmp = h2->GetBinContent(h2->GetBin(i,j));
131  h2->SetBinContent(h2->GetBin(i,j), tmp+(Double_t)fCounts);
132  }
133  }
134 
135  DeleteTree();
136  GetHistoTot("x")->Reset("ICE");
137  }
138  }
139 }
140 
141 
TBrowser * b
CorrelatedSpaceTree2 class that manages a 2D symmetrical correlated space stored in a tree In the ent...
LogMessage & warning(LogMessage &)
header file for all type of CorrelatedSpaceTree2I
void FillCounts(Int_t i, Int_t j, TH2 *h2)
fill counts
TBranch * SetAddress()
Set address.
TString fBranchName
tree that contains the matrix
void FillHisto(Int_t j, TH1 *h)
Fill histo.
LogMessage & dolog(LogMessage &)
CorrelatedSpaceTree2I class that manages a 2D symmetrical correlated space of integers store in a tre...
virtual TH1D * GetHistoTot(Option_t *axis="x")
Get histo total projection.
void CheckH2InTree(TH2 *h2)
Check if h2 already in tree.
void DeleteTree(Option_t *opt="")
Reset Tree.
void SetCounts(Double_t weight)
Set counts.
ClassImp(CorrelatedSpaceTree2I) CorrelatedSpaceTree2I