AliPhysics  5eaf189 (5eaf189)
THistManager.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <cfloat>
16 #include <cstring>
17 #include <iostream> // for unit tests
18 #include <sstream>
19 #include <string>
20 #include <exception>
21 #include <vector>
22 #include <TArrayD.h>
23 #include <TAxis.h>
24 #include <TH1.h>
25 #include <TH2.h>
26 #include <TH3.h>
27 #include <THnSparse.h>
28 #include <THashList.h>
29 #include <TMath.h>
30 #include <TObjArray.h>
31 #include <TObjString.h>
32 #include <TProfile.h>
33 #include <TString.h>
34 
35 #include "TBinning.h"
36 #include "THistManager.h"
37 
39 ClassImp(THistManager)
41 
43  TNamed(),
44  fHistos(NULL),
45  fIsOwner(true)
46 {
47 }
48 
49 THistManager::THistManager(const char *name):
50  TNamed(name, Form("Histogram container %s", name)),
51  fHistos(NULL),
52  fIsOwner(true)
53 {
54  fHistos = new THashList();
55  fHistos->SetName(Form("histos%s", name));
56  fHistos->SetOwner();
57 }
58 
60  if(fHistos && fIsOwner) delete fHistos;
61 }
62 
63 THashList* THistManager::CreateHistoGroup(const char *groupname) {
64  // At first step check whether the group already exists.
65  THashList *foundgroup = FindGroup(groupname);
66  if(foundgroup){
67  // already existing, don't create it again
68  return foundgroup;
69  }
70  TString parentname = basename(groupname);
71  THashList *parentgroup = FindGroup(parentname);
72  if(!parentgroup) parentgroup = CreateHistoGroup(parentname);
73  THashList *childgroup = new THashList();
74  childgroup->SetName(histname(groupname));
75  childgroup->SetOwner();
76  parentgroup->Add(childgroup);
77  return childgroup;
78 }
79 
80 TH1* THistManager::CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt){
81  TString dirname(basename(name)), hname(histname(name));
82  THashList *parent(FindGroup(dirname));
83  if(!parent) parent = CreateHistoGroup(dirname);
84  if(parent->FindObject(hname)){
85  Fatal("THistManager::CreateTH1", "Object %s already exists in group %s", hname.Data(), dirname.Data());
86  return 0;
87  }
88  TH1* h = new TH1D(hname, title, nbins, xmin, xmax);
89  TString optionstring(opt);
90  optionstring.ToLower();
91  if(optionstring.Contains("s"))
92  h->Sumw2();
93  parent->Add(h);
94  return h;
95 }
96 
97 TH1* THistManager::CreateTH1(const char *name, const char *title, int nbins, const double *xbins, Option_t *opt){
98  TString dirname(basename(name)), hname(histname(name));
99  THashList *parent(FindGroup(dirname));
100  if(!parent) parent = CreateHistoGroup(dirname);
101  if(parent->FindObject(hname)){
102  Fatal("THistManager::CreateTH1", "Object %s already exists in group %s", hname.Data(), dirname.Data());
103  return 0;
104  }
105  TH1* h = new TH1D(hname, title, nbins, xbins);
106  TString optionstring(opt);
107  optionstring.ToLower();
108  if(optionstring.Contains("s"))
109  h->Sumw2();
110  parent->Add(h);
111  return h;
112 }
113 
114 TH1* THistManager::CreateTH1(const char *name, const char *title, const TArrayD &xbins, Option_t *opt){
115  TString dirname(basename(name)), hname(histname(name));
116  THashList *parent(FindGroup(dirname));
117  if(!parent) parent = CreateHistoGroup(dirname);
118  if(parent->FindObject(hname)){
119  Fatal("THistManager::CreateTH1", "Object %s already exists in group %s", hname.Data(), dirname.Data());
120  return 0;
121  }
122  TH1* h = new TH1D(hname, title, xbins.GetSize()-1, xbins.GetArray());
123  TString optionstring(opt);
124  optionstring.ToLower();
125  if(optionstring.Contains("s"))
126  h->Sumw2();
127  parent->Add(h);
128  return h;
129 }
130 
131 TH1* THistManager::CreateTH1(const char *name, const char *title, const TBinning &xbin, Option_t *opt){
132  TArrayD myxbins;
133  try{
134  xbin.CreateBinEdges(myxbins);
135  } catch(std::exception &e){
136  Fatal("THistManager::CreateTH1", "Exception raised: %s", e.what());
137  }
138  return CreateTH1(name, title, myxbins, opt);
139 }
140 
141 TH2* THistManager::CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt){
142  TString dirname(basename(name)), hname(histname(name));
143  THashList *parent(FindGroup(dirname));
144  if(!parent) parent = CreateHistoGroup(dirname);
145  if(parent->FindObject(hname)){
146  Fatal("THistManager::CreateTH2", "Object %s already exists in group %s", hname.Data(), dirname.Data());
147  return 0;
148  }
149  TH2* h = new TH2D(hname, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax);
150  TString optionstring(opt);
151  optionstring.ToLower();
152  if(optionstring.Contains("s"))
153  h->Sumw2();
154  parent->Add(h);
155  return h;
156 }
157 
158 TH2* THistManager::CreateTH2(const char *name, const char *title, int nbinsx, const double *xbins, int nbinsy, const double *ybins, Option_t *opt){
159  TString dirname(basename(name)), hname(histname(name));
160  THashList *parent(FindGroup(dirname));
161  if(!parent) parent = CreateHistoGroup(dirname);
162  if(parent->FindObject(hname)){
163  Fatal("THistManager::CreateTH2", "Object %s already exists in group %s", hname.Data(), dirname.Data());
164  return 0;
165  }
166  TH2* h = new TH2D(hname, title, nbinsx, xbins, nbinsy, ybins);
167  TString optionstring(opt);
168  optionstring.ToLower();
169  if(optionstring.Contains("s"))
170  h->Sumw2();
171  parent->Add(h);
172  return h;
173 }
174 
175 TH2* THistManager::CreateTH2(const char *name, const char *title, const TArrayD &xbins, const TArrayD &ybins, Option_t *opt){
176  TString dirname(basename(name)), hname(histname(name));
177  THashList *parent(FindGroup(dirname));
178  if(!parent) parent = CreateHistoGroup(dirname);
179  if(parent->FindObject(hname)){
180  Fatal("THistManager::CreateTH2", "Object %s already exists in group %s", hname.Data(), dirname.Data());
181  return 0;
182  }
183  TH2* h = new TH2D(hname, title, xbins.GetSize() - 1, xbins.GetArray(), ybins.GetSize() - 1, ybins.GetArray());
184  TString optionstring(opt);
185  optionstring.ToLower();
186  if(optionstring.Contains("s"))
187  h->Sumw2();
188  parent->Add(h);
189  return h;
190 }
191 
192 TH2* THistManager::CreateTH2(const char *name, const char *title, const TBinning &xbins, const TBinning &ybins, Option_t *opt){
193  TArrayD myxbins, myybins;
194  try{
195  xbins.CreateBinEdges(myxbins);
196  } catch (std::exception &e) {
197  Fatal("THistManager::CreateTH2 (x-dir)", "Exception raised: %s", e.what());
198  }
199  try{
200  ybins.CreateBinEdges(myybins);
201  } catch (std::exception &e) {
202  Fatal("THistManager::CreateTH2 (y-dir)", "Exception raised: %s", e.what());
203  }
204 
205  return CreateTH2(name, title, myxbins, myybins, opt);
206 }
207 
208 TH3* THistManager::CreateTH3(const char* name, const char* title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, int nbinsz, double zmin, double zmax, Option_t *opt) {
209  TString dirname(basename(name)), hname(histname(name));
210  THashList *parent(FindGroup(dirname));
211  if(!parent) parent = CreateHistoGroup(dirname);
212  if(parent->FindObject(hname)){
213  Fatal("THistManager::CreateTH3", "Object %s already exists in group %s", hname.Data(), dirname.Data());
214  return 0;
215  }
216  TH3* h = new TH3D(hname, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax, nbinsz, zmin, zmax);
217  TString optionstring(opt);
218  optionstring.ToLower();
219  if(optionstring.Contains("s"))
220  h->Sumw2();
221  parent->Add(h);
222  return h;
223 }
224 
225 TH3* THistManager::CreateTH3(const char* name, const char* title, int nbinsx, const double* xbins, int nbinsy, const double* ybins, int nbinsz, const double* zbins, Option_t *opt) {
226  TString dirname(basename(name)), hname(histname(name));
227  THashList *parent(FindGroup(dirname));
228  if(!parent) parent = CreateHistoGroup(dirname);
229  if(parent->FindObject(hname)){
230  Fatal("THistManager::CreateTH3", "Object %s already exists in group %s", hname.Data(), dirname.Data());
231  return 0;
232  }
233  TH3* h = new TH3D(hname, title, nbinsx, xbins, nbinsy, ybins, nbinsz, zbins);
234  TString optionstring(opt);
235  optionstring.ToLower();
236  if(optionstring.Contains("s"))
237  h->Sumw2();
238  parent->Add(h);
239  return h;
240 }
241 
242 TH3* THistManager::CreateTH3(const char* name, const char* title, const TArrayD& xbins, const TArrayD& ybins, const TArrayD& zbins, Option_t *opt) {
243  TString dirname(basename(name)), hname(histname(name));
244  THashList *parent(FindGroup(dirname));
245  if(!parent) parent = CreateHistoGroup(dirname);
246  if(parent->FindObject(hname)){
247  Fatal("THistManager::CreateTH3", "Object %s already exists in group %s", hname.Data(), dirname.Data());
248  return 0;
249  }
250  TH3* h = new TH3D(hname, title, xbins.GetSize()-1, xbins.GetArray(), ybins.GetSize()-1, ybins.GetArray(), zbins.GetSize()-1, zbins.GetArray());
251  TString optionstring(opt);
252  optionstring.ToLower();
253  if(optionstring.Contains("s"))
254  h->Sumw2();
255  parent->Add(h);
256  return h;
257 }
258 
259 TH3* THistManager::CreateTH3(const char *name, const char *title, const TBinning &xbins, const TBinning &ybins, const TBinning &zbins, Option_t *opt){
260  TArrayD myxbins, myybins, myzbins;
261  try{
262  xbins.CreateBinEdges(myxbins);
263  } catch (std::exception &e) {
264  Fatal("THistManager::CreateTH2 (x-dir)", "Exception raised: %s", e.what());
265  }
266  try{
267  ybins.CreateBinEdges(myybins);
268  } catch (std::exception &e) {
269  Fatal("THistManager::CreateTH2 (y-dir)", "Exception raised: %s", e.what());
270  }
271  try{
272  zbins.CreateBinEdges(myzbins);
273  } catch (std::exception &e) {
274  Fatal("THistManager::CreateTH2 (z-dir)", "Exception raised: %s", e.what());
275  }
276 
277  return CreateTH3(name, title, myxbins, myybins, myzbins);
278 }
279 
280 THnSparse* THistManager::CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt) {
281  TString dirname(basename(name)), hname(histname(name));
282  THashList *parent(FindGroup(dirname));
283  if(!parent) parent = CreateHistoGroup(dirname);
284  if(parent->FindObject(hname)){
285  Fatal("THistManager::CreateTHnSparse", "Object %s already exists in group %s", hname.Data(), dirname.Data());
286  return 0;
287  }
288  THnSparse* h = new THnSparseD(hname, title, ndim, nbins, min, max);
289  TString optionstring(opt);
290  optionstring.ToLower();
291  if(optionstring.Contains("s"))
292  h->Sumw2();
293  parent->Add(h);
294  return h;
295 }
296 
297 THnSparse* THistManager::CreateTHnSparse(const char *name, const char *title, int ndim, const TAxis **axes, Option_t *opt) {
298  TString dirname(basename(name)), hname(histname(name));
299  THashList *parent(FindGroup(dirname));
300  if(!parent) parent = CreateHistoGroup(dirname);
301  if(parent->FindObject(hname)){
302  Fatal("THistManager::CreateTHnSparse", "Object %s already exists in group %s", hname.Data(), dirname.Data());
303  return 0;
304  }
305  TArrayD xmin(ndim), xmax(ndim);
306  TArrayI nbins(ndim);
307  for(int idim = 0; idim < ndim; ++idim){
308  const TAxis &myaxis = *(axes[idim]);
309  nbins[idim] = myaxis.GetNbins();
310  xmin[idim] = myaxis.GetXmin();
311  xmax[idim] = myaxis.GetXmax();
312  }
313  THnSparseD *hsparse = new THnSparseD(hname, title, ndim, nbins.GetArray(), xmin.GetArray(), xmax.GetArray());
314  for(int id = 0; id < ndim; ++id)
315  *(hsparse->GetAxis(id)) = *(axes[id]);
316  TString optionstring(opt);
317  optionstring.ToLower();
318  if(optionstring.Contains("s"))
319  hsparse->Sumw2();
320  parent->Add(hsparse);
321  return hsparse;
322 }
323 
324 THnSparse* THistManager::CreateTHnSparse(const char *name, const char *title, int ndim, const TBinning **axes, Option_t *opt){
325  TString dirname(basename(name)), hname(histname(name));
326  THashList *parent(FindGroup(dirname));
327  if(!parent) parent = CreateHistoGroup(dirname);
328  if(parent->FindObject(hname)){
329  Fatal("THistManager::CreateTHnSparse", "Object %s already exists in group %s", hname.Data(), dirname.Data());
330  return 0;
331  }
332  TArrayD xmin(ndim), xmax(ndim);
333  TArrayI nbins(ndim);
334  std::vector<TArrayD> binnings;
335  for(int idim = 0; idim < ndim; ++idim){
336  const TBinning &myaxis = *(axes[idim]);
337  TArrayD binEdges;
338  myaxis.CreateBinEdges(binEdges);
339  nbins[idim] = binEdges.GetSize()-1;
340  xmin[idim] = binEdges[0];
341  xmax[idim] = binEdges[binEdges.GetSize()-1];
342  binnings.push_back(binEdges);
343  }
344  THnSparseD *hsparse = new THnSparseD(hname, title, ndim, nbins.GetArray(), xmin.GetArray(), xmax.GetArray());
345  for(int id = 0; id < ndim; ++id){
346  TArrayD &binEdges = binnings[id];
347  hsparse->GetAxis(id)->Set(binEdges.GetSize()-1, binEdges.GetArray());
348  }
349  TString optionstring(opt);
350  optionstring.ToLower();
351  if(optionstring.Contains("s"))
352  hsparse->Sumw2();
353  parent->Add(hsparse);
354  return hsparse;
355 }
356 
357 void THistManager::CreateTProfile(const char* name, const char* title, int nbinsX, double xmin, double xmax, Option_t *opt) {
358  TString dirname(basename(name)), hname(histname(name));
359  THashList *parent(FindGroup(dirname));
360  if(!parent) parent = CreateHistoGroup(dirname);
361  if(parent->FindObject(hname))
362  Fatal("THistManager::CreateTProfile", "Object %s already exists in group %s", hname.Data(), dirname.Data());
363  TProfile *hist = new TProfile(hname, title, nbinsX, xmin, xmax, opt);
364  parent->Add(hist);
365 }
366 
367 void THistManager::CreateTProfile(const char* name, const char* title, int nbinsX, const double* xbins, Option_t *opt) {
368  TString dirname(basename(name)), hname(histname(name));
369  THashList *parent(FindGroup(dirname));
370  if(!parent) parent = CreateHistoGroup(dirname);
371  if(parent->FindObject(hname))
372  Fatal("THistManager::CreateTHnSparse", "Object %s already exists in group %s", hname.Data(), dirname.Data());
373  TProfile *hist = new TProfile(hname, title, nbinsX, xbins, opt);
374  parent->Add(hist);
375 }
376 
377 void THistManager::CreateTProfile(const char* name, const char* title, const TArrayD& xbins, Option_t *opt){
378  TString dirname(basename(name)), hname(histname(name));
379  THashList *parent(FindGroup(dirname));
380  if(!parent) parent = CreateHistoGroup(dirname);
381  if(parent->FindObject(hname))
382  Fatal("THistManager::CreateTHnSparse", "Object %s already exists in group %s", hname.Data(), dirname.Data());
383  TProfile *hist = new TProfile(hname.Data(), title, xbins.GetSize()-1, xbins.GetArray(), opt);
384  parent->Add(hist);
385 }
386 
387 void THistManager::CreateTProfile(const char *name, const char *title, const TBinning &xbins, Option_t *opt){
388  TArrayD myxbins;
389  try{
390  xbins.CreateBinEdges(myxbins);
391  } catch (std::exception &e){
392  Fatal("THistManager::CreateProfile", "Exception raised: %s", e.what());
393  }
394  CreateTProfile(name, title, myxbins, opt);
395 }
396 
397 void THistManager::SetObject(TObject * const o, const char *group) {
398  THashList *parent(FindGroup(group));
399  if(!parent) CreateHistoGroup(group);
400  if(parent->FindObject(o->GetName())){
401  Fatal("THistManager::SetObject", "Parent %s does not exist", strcmp(group, "/") ? group : "");
402  return;
403  }
404  if(!(dynamic_cast<THnBase *>(o) || dynamic_cast<TH1 *>(o))){
405  Fatal("THistManager::SetObject", "Object %s is not of a histogram type",o->GetName());
406  return;
407  }
408  fHistos->Add(o);
409 }
410 
411 void THistManager::FillTH1(const char *name, double x, double weight, Option_t *opt) {
412  TString dirname(basename(name)), hname(histname(name));
413  THashList *parent(FindGroup(dirname));
414  if(!parent){
415  Fatal("THistManager::FillTH1", "Parent group %s does not exist", dirname.Data());
416  return;
417  }
418  TH1 *hist = dynamic_cast<TH1 *>(parent->FindObject(hname));
419  if(!hist){
420  Fatal("THistManager::FillTH1", "Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
421  return;
422  }
423  TString optionstring(opt);
424  if(optionstring.Contains("w")){
425  // use bin width as weight
426  Int_t bin = hist->GetXaxis()->FindBin(x);
427  // check if not overflow or underflow bin
428  if(bin != 0 && bin != hist->GetXaxis()->GetNbins())
429  weight = 1./hist->GetXaxis()->GetBinWidth(bin);
430  }
431  hist->Fill(x, weight);
432 }
433 
434 void THistManager::FillTH1(const char *name, const char *label, double weight, Option_t *opt) {
435  TString dirname(basename(name)), hname(histname(name));
436  THashList *parent(FindGroup(dirname));
437  if(!parent){
438  Fatal("THistManager::FillTH1", "Parent group %s does not exist", dirname.Data());
439  return;
440  }
441  TH1 *hist = dynamic_cast<TH1 *>(parent->FindObject(hname));
442  if(!hist){
443  Fatal("THistManager::FillTH1", "Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
444  return;
445  }
446  TString optionstring(opt);
447  if(optionstring.Contains("w")){
448  // use bin width as weight
449  // get bin for label
450  Int_t bin = hist->GetXaxis()->FindBin(label);
451  // check if not overflow or underflow bin
452  if(bin != 0 && bin != hist->GetXaxis()->GetNbins())
453  weight = 1./hist->GetXaxis()->GetBinWidth(bin);
454  }
455  hist->Fill(label, weight);
456 }
457 
458 void THistManager::FillTH2(const char *name, double x, double y, double weight, Option_t *opt) {
459  TString dirname(basename(name)), hname(histname(name));
460  THashList *parent(FindGroup(dirname));
461  if(!parent){
462  Fatal("THistManager::FillTH2", "Parent group %s does not exist", dirname.Data());
463  return;
464  }
465  TH2 *hist = dynamic_cast<TH2 *>(parent->FindObject(hname));
466  if(!hist){
467  Fatal("THistManager::FillTH2", "Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
468  return;
469  }
470  TString optstring(opt);
471  Double_t myweight = optstring.Contains("w") ? 1. : weight;
472  if(optstring.Contains("wx")){
473  Int_t binx = hist->GetXaxis()->FindBin(x);
474  if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
475  }
476  if(optstring.Contains("wy")){
477  Int_t biny = hist->GetYaxis()->FindBin(y);
478  if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
479  }
480  hist->Fill(x, y, myweight);
481 }
482 
483 void THistManager::FillTH2(const char *name, double *point, double weight, Option_t *opt) {
484  TString dirname(basename(name)), hname(histname(name));
485  THashList *parent(FindGroup(dirname));
486  if(!parent){
487  Fatal("THistManager::FillTH2", "Parent group %s does not exist", dirname.Data());
488  return;
489  }
490  TH2 *hist = dynamic_cast<TH2 *>(parent->FindObject(hname));
491  if(!hist){
492  Fatal("THistManager::FillTH2", "Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
493  return;
494  }
495  TString optstring(opt);
496  Double_t myweight = optstring.Contains("w") ? 1. : weight;
497  if(optstring.Contains("wx")){
498  Int_t binx = hist->GetXaxis()->FindBin(point[0]);
499  if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
500  }
501  if(optstring.Contains("wy")){
502  Int_t biny = hist->GetYaxis()->FindBin(point[1]);
503  if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
504  }
505  hist->Fill(point[0], point[1], weight);
506 }
507 
508 void THistManager::FillTH2(const char *name, const char *labelX, const char *labelY, double weight, Option_t *opt) {
509  TString dirname(basename(name)), hname(histname(name));
510  THashList *parent(FindGroup(dirname));
511  if(!parent){
512  Fatal("THistManager::FillTH2", "Parent group %s does not exist", dirname.Data());
513  return;
514  }
515  TH2 *hist = dynamic_cast<TH2 *>(parent->FindObject(hname));
516  if(!hist){
517  Fatal("THistManager::FillTH2", "Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
518  return;
519  }
520  TString optstring(opt);
521  Double_t myweight = optstring.Contains("w") ? 1. : weight;
522  if(optstring.Contains("wx")){
523  Int_t binx = hist->GetXaxis()->FindBin(labelY);
524  if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
525  }
526  if(optstring.Contains("wy")){
527  Int_t biny = hist->GetYaxis()->FindBin(labelX);
528  if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
529  }
530  hist->Fill(labelX, labelY, weight);
531 }
532 
533 void THistManager::FillTH3(const char* name, double x, double y, double z, double weight, Option_t *opt) {
534  TString dirname(basename(name)), hname(histname(name));
535  THashList *parent(FindGroup(dirname));
536  if(!parent){
537  Fatal("THistManager::FillTH3", "Parent group %s does not exist", dirname.Data());
538  return;
539  }
540  TH3 *hist = dynamic_cast<TH3 *>(parent->FindObject(hname));
541  if(!hist){
542  Fatal("THistManager::FillTH3", "Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
543  return;
544  }
545  TString optstring(opt);
546  Double_t myweight = optstring.Contains("w") ? 1. : weight;
547  if(optstring.Contains("wx")){
548  Int_t binx = hist->GetXaxis()->FindBin(x);
549  if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
550  }
551  if(optstring.Contains("wy")){
552  Int_t biny = hist->GetYaxis()->FindBin(y);
553  if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
554  }
555  if(optstring.Contains("wz")){
556  Int_t binz = hist->GetZaxis()->FindBin(z);
557  if(binz != 0 && binz != hist->GetZaxis()->GetNbins()) myweight *= 1./hist->GetZaxis()->GetBinWidth(binz);
558  }
559  hist->Fill(x, y, z, weight);
560 }
561 
562 void THistManager::FillTH3(const char* name, const double* point, double weight, Option_t *opt) {
563  TString dirname(basename(name)), hname(histname(name));
564  THashList *parent(FindGroup(dirname));
565  if(!parent){
566  Fatal("THistManager::FillTH3", "Parent group %s does not exist", dirname.Data());
567  return;
568  }
569  TH3 *hist = dynamic_cast<TH3 *>(parent->FindObject(hname));
570  if(!hist){
571  Fatal("THistManager::FillTH3", "Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
572  return;
573  }
574  TString optstring(opt);
575  Double_t myweight = optstring.Contains("w") ? 1. : weight;
576  if(optstring.Contains("wx")){
577  Int_t binx = hist->GetXaxis()->FindBin(point[0]);
578  if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
579  }
580  if(optstring.Contains("wy")){
581  Int_t biny = hist->GetYaxis()->FindBin(point[1]);
582  if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
583  }
584  if(optstring.Contains("wz")){
585  Int_t binz = hist->GetZaxis()->FindBin(point[2]);
586  if(binz != 0 && binz != hist->GetZaxis()->GetNbins()) myweight *= 1./hist->GetZaxis()->GetBinWidth(binz);
587  }
588  hist->Fill(point[0], point[1], point[2], weight);
589 }
590 
591 void THistManager::FillTHnSparse(const char *name, const double *x, double weight, Option_t *opt) {
592  TString dirname(basename(name)), hname(histname(name));
593  THashList *parent(FindGroup(dirname));
594  if(!parent){
595  Fatal("THistManager::FillTHnSparse", "Parent group %s does not exist", dirname.Data());
596  return;
597  }
598  THnSparseD *hist = dynamic_cast<THnSparseD *>(parent->FindObject(hname));
599  if(!hist){
600  Fatal("THistManager::FillTHnSparse", "Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
601  return;
602  }
603  TString optstring(opt);
604  Double_t myweight = optstring.Contains("w") ? 1. : weight;
605  for(Int_t iaxis = 0; iaxis < hist->GetNdimensions(); iaxis++){
606  std::stringstream weighthandler;
607  weighthandler << "w" << iaxis;
608  if(optstring.Contains(weighthandler.str().c_str())){
609  Int_t bin = hist->GetAxis(iaxis)->FindBin(x[iaxis]);
610  if(bin != 0 && bin != hist->GetAxis(iaxis)->GetNbins()) myweight *= hist->GetAxis(iaxis)->GetBinWidth(bin);
611  }
612  }
613 
614  hist->Fill(x, weight);
615 }
616 
617 void THistManager::FillProfile(const char* name, double x, double y, double weight){
618  TString dirname(basename(name)), hname(histname(name));
619  THashList *parent(FindGroup(dirname));
620  if(!parent)
621  Fatal("THistManager::FillTProfile", "Parent group %s does not exist", dirname.Data());
622  TProfile *hist = dynamic_cast<TProfile *>(parent->FindObject(hname));
623  if(!hist)
624  Fatal("THistManager::FillTProfile", "Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
625  hist->Fill(x, y, weight);
626 }
627 
628 TObject *THistManager::FindObject(const char *name) const {
629  TString dirname(basename(name)), hname(histname(name));
630  THashList *parent(FindGroup(dirname));
631  if(!parent) return NULL;
632  return parent->FindObject(hname);
633 }
634 
636  TString dirname(basename(obj->GetName())), hname(histname(obj->GetName()));
637  THashList *parent(FindGroup(dirname));
638  if(!parent) return NULL;
639  return parent->FindObject(hname);
640 }
641 
642 THashList *THistManager::FindGroup(const char *dirname) const {
643  if(!strlen(dirname) || !strcmp(dirname, "/")) return fHistos;
644  // recursive find - avoids tokenizing filename
645  THashList *parentlist = FindGroup(basename(dirname));
646  if(parentlist) return static_cast<THashList *>(parentlist->FindObject(histname(dirname)));
647  return nullptr;
648 }
649 
651  int index = path.Last('/');
652  if(index < 0) return ""; // no directory structure
653  return TString(path(0, index));
654 }
655 
657  int index = path.Last('/');
658  if(index < 0) return path; // no directory structure
659  return TString(path(index+1, path.Length() - (index+1)));
660 }
661 
667 
669  fkArray(hmgr),
670  fCurrentPos(),
671  fNext(),
672  fDirection(dir)
673 {}
674 
676  fkArray(ref.fkArray),
678  fNext(ref.fNext),
680 {}
681 
683  if(this != &ref){
684  fkArray = ref.fkArray;
685  fCurrentPos = ref.fCurrentPos;
686  fNext = ref.fNext;
687  fDirection = ref.fDirection;
688  }
689  return *this;
690 }
691 
693  return fCurrentPos == other.fCurrentPos;
694 }
695 
697  if(fDirection == kTHMIforward)
698  fCurrentPos++;
699  else
700  fCurrentPos--;
701  return *this;
702 }
703 
705  iterator tmp(*this);
706  operator++();
707  return tmp;
708 }
709 
711  if(fDirection == kTHMIforward)
712  fCurrentPos--;
713  else
714  fCurrentPos++;
715  return *this;
716 };
717 
719  iterator tmp(*this);
720  operator--();
721  return tmp;
722 };
723 
725  if(fCurrentPos >=0 && fCurrentPos < fkArray->GetListOfHistograms()->GetEntries())
726  return fkArray->GetListOfHistograms()->At(fCurrentPos);
727  return NULL;
728 }
729 
730 
736 
737 namespace TestTHistManager {
738 
739  int THistManagerTestSuite::TestBuildSimpleHistograms(){
740  THistManager testmgr("testmgr");
741 
742  // Create histogram of each type
743  testmgr.CreateTH1("Test1D", "Test Histogram 1D", 1, 0., 1.);
744  testmgr.CreateTH2("Test2D", "Test Histogram 2D", 2, 0., 2., 10., 0., 10);
745  testmgr.CreateTH3("Test3D", "Test Histogram 3D", 3, 2, 6., 10., 0., 10., 50., 0., 50.);
746  int nbins[3] = {3, 3, 3}; double min[3] = {0., 0., 0}, max[3] = {6, 9, 12}; // dimensions for THnSparseTest
747  testmgr.CreateTHnSparse("TestNSparse", "Test Histogram NSparse", 3, nbins, min, max);
748  testmgr.CreateTProfile("TestProfile", "Test TProfile", 1, 0., 1);
749 
750  // Find histograms in the list (evaluate test)
751  // Tell user why test has failed
752  Bool_t found(true);
753  if(!dynamic_cast<TH1 *>(testmgr.GetListOfHistograms()->FindObject("Test1D"))){
754  std::cout << "Not found: Test1D" << std::endl;
755  found = false;
756  }
757  if(!dynamic_cast<TH2 *>(testmgr.GetListOfHistograms()->FindObject("Test2D"))){
758  std::cout << "Not found: Test2D" << std::endl;
759  found = false;
760  }
761  if(!dynamic_cast<TH3 *>(testmgr.GetListOfHistograms()->FindObject("Test3D"))){
762  std::cout << "Not found: Test3D" << std::endl;
763  found = false;
764  }
765  if(!dynamic_cast<THnSparse *>(testmgr.GetListOfHistograms()->FindObject("TestNSparse"))){
766  std::cout << "Not found: TestNSparse" << std::endl;
767  found = false;
768  }
769  if(!dynamic_cast<TProfile *>(testmgr.GetListOfHistograms()->FindObject("TestProfile"))){
770  std::cout << "Not found: TestProfile" << std::endl;
771  found = false;
772  }
773 
774  return found ? 0 : 1;
775  }
776 
777  int THistManagerTestSuite::TestBuildGroupedHistograms(){
778  THistManager testmgr("testmgr");
779 
780  // Creating 3 groups
781  testmgr.CreateTH1("Group1/Test1", "Test Histogram 1 in group 1", 1, 0., 1.);
782  testmgr.CreateTH1("Group1/Test2", "Test Histogram 2 in group 1", 1, 0., 1.);
783  testmgr.CreateTH2("Group2/Test1", "Test Histogram 1 in group 2", 1, 0., 1., 1, 0., 1.);
784  testmgr.CreateTH2("Group2/Test2", "Test Histogram 2 in group 2", 1, 0., 1., 1, 0., 1.);
785  testmgr.CreateTH3("Group3/Test1", "Test Histogram 1 in group 3", 1, 0., 1., 1, 0., 1., 1, 0., 1.);
786  testmgr.CreateTH3("Group3/Test2", "Test Histogram 2 in group 3", 1, 0., 1., 1, 0., 1., 1, 0., 1.);
787  // Creating histogram in a subgroup
788  testmgr.CreateTProfile("Group4/Subgroup1/Test1", "Test histogram for subgroup handling", 1, 0., 1);
789 
790  // Evalutate test
791  // Tell user why test has failed
792  Bool_t found(true);
793  THashList *currentdir(nullptr);
794  if(!(currentdir = dynamic_cast<THashList *>(testmgr.GetListOfHistograms()->FindObject("Group1")))){
795  std::cout << "Not found: Group1" << std::endl;
796  found = false;
797  } else {
798  if(!dynamic_cast<TH1 *>(currentdir->FindObject("Test1"))){
799  std::cout << "Not found in Group1: Test1" << std::endl;
800  found = false;
801  }
802  if(!dynamic_cast<TH1 *>(currentdir->FindObject("Test2"))){
803  std::cout << "Not found in Group1: Test2" << std::endl;
804  found = false;
805  }
806  }
807  if(!(currentdir = dynamic_cast<THashList *>(testmgr.GetListOfHistograms()->FindObject("Group2")))){
808  std::cout << "Not found: Group2" << std::endl;
809  found = false;
810  } else {
811  if(!dynamic_cast<TH2 *>(currentdir->FindObject("Test1"))){
812  std::cout << "Not found in Group2: Test1" << std::endl;
813  found = false;
814  }
815  if(!dynamic_cast<TH2 *>(currentdir->FindObject("Test2"))){
816  std::cout << "Not found in Group2: Test2" << std::endl;
817  found = false;
818  }
819  }
820  if(!(currentdir = dynamic_cast<THashList *>(testmgr.GetListOfHistograms()->FindObject("Group3")))){
821  std::cout << "Not found: Group3" << std::endl;
822  found = false;
823  } else {
824  if(!static_cast<TH3 *>(currentdir->FindObject("Test1"))){
825  std::cout << "Not found in Group3: Test1" << std::endl;
826  found = false;
827  }
828  if(!static_cast<TH3 *>(currentdir->FindObject("Test2"))){
829  std::cout << "Not found in Group3: Test2" << std::endl;
830  found = false;
831  }
832  }
833  if(!(currentdir = dynamic_cast<THashList *>(testmgr.GetListOfHistograms()->FindObject("Group4")))){
834  std::cout << "Not found: Group4" << std::endl;
835  found = false;
836  } else {
837  if(!(currentdir = dynamic_cast<THashList *>(currentdir->FindObject("Subgroup1")))){
838  std::cout << "Not found in Group4: Subgroup1" << std::endl;
839  found = false;
840  } else {
841  if(!dynamic_cast<TH1 *>(currentdir->FindObject("Test1"))){
842  std::cout << "Not found in Subgroup1: Test1" << std::endl;
843  found = false;
844  }
845  }
846  }
847  return found ? 0 : 1;
848  }
849 
850  int THistManagerTestSuite::TestFillSimpleHistograms(){
851  THistManager testmgr("testmgr");
852 
853  testmgr.CreateTH1("Test1", "Test fill 1D histogram", 1, 0., 1.);
854  testmgr.CreateTH2("Test2", "Test fill 2D histogram", 1, 0., 1., 1, 0., 1.);
855  testmgr.CreateTH3("Test3", "Test fill 3D histogram", 1, 0., 1., 1, 0., 1., 1, 0., 1.);
856  int nbins[4] = {1,1,1,1}; double min[4] = {0.,0.,0.,0.}, max[4] = {1.,1.,1.,1.};
857  testmgr.CreateTHnSparse("TestN", "Test Fill THnSparse", 4, nbins, min, max);
858  testmgr.CreateTProfile("TestProfile", "Test fill Profile histogram", 1, 0., 1.);
859 
860  double point[4] = {0.5, 0.5, 0.5, 0.5};
861  for(int i = 0; i < 100; i++){
862  testmgr.FillTH1("Test1", 0.5);
863  testmgr.FillTH2("Test2", 0.5, 0.5);
864  testmgr.FillTH3("Test3", 0.5, 0.5, 0.5);
865  testmgr.FillProfile("TestProfile", 0.5, 1.);
866  testmgr.FillTHnSparse("TestN", point);
867  }
868 
869  // Evalutate test
870  // tell user why test has failed
871  bool success(true);
872 
873  TH1 *test1 = dynamic_cast<TH1 *>(testmgr.GetListOfHistograms()->FindObject("Test1"));
874  if(test1){
875  if(TMath::Abs(test1->GetBinContent(1) - 100) > DBL_EPSILON){
876  std::cout << "Test1: Mismatch in values, expected 100, found " << test1->GetBinContent(1) << std::endl;
877  success = false;
878  }
879  } else {
880  std::cout << "Not found: Test1" << std::endl;
881  success = false;
882  }
883 
884  TH2 *test2 = dynamic_cast<TH2 *>(testmgr.GetListOfHistograms()->FindObject("Test2"));
885  if(test2){
886  if(TMath::Abs(test2->GetBinContent(1, 1) - 100) > DBL_EPSILON){
887  std::cout << "Test2: Mismatch in values, expected 100, found " << test2->GetBinContent(1,1) << std::endl;
888  success = false;
889  }
890  } else {
891  std::cout << "Not found: Test2" << std::endl;
892  success = false;
893  }
894 
895  TH3 *test3 = dynamic_cast<TH3 *>(testmgr.GetListOfHistograms()->FindObject("Test3"));
896  if(test3){
897  if(TMath::Abs(test3->GetBinContent(1, 1, 1) - 100) > DBL_EPSILON){
898  std::cout << "Test3: Mismatch in values, expected 100, found " << test3->GetBinContent(1,1,1) << std::endl;
899  success = false;
900  }
901  } else {
902  std::cout << "Not found: Test3" << std::endl;
903  success = false;
904  }
905 
906  THnSparse *testN = dynamic_cast<THnSparse *>(testmgr.GetListOfHistograms()->FindObject("TestN"));
907  if(testN){
908  int index[4] = {1,1,1,1};
909  if(TMath::Abs(testN->GetBinContent(index) - 100) > DBL_EPSILON){
910  std::cout << "TestN: Mismatch in values, expected 100, found " << testN->GetBinContent(index) << std::endl;
911  success = false;
912  }
913  } else {
914  std::cout << "Not found: TestN" << std::endl;
915  success = false;
916  }
917 
918  TProfile *testProfile = dynamic_cast<TProfile *>(testmgr.GetListOfHistograms()->FindObject("TestProfile"));
919  if(testProfile){
920  if(TMath::Abs(testProfile->GetBinContent(1) - 1) > DBL_EPSILON){
921  std::cout << "TestProfile: Mismatch in values, expected 1, found " << testProfile->GetBinContent(1) << std::endl;
922  success = false;
923  }
924  } else {
925  std::cout << "Not found: TestProfile" << std::endl;
926  success = false;
927  }
928 
929  return success ? 0 : 1;
930  }
931 
932 
933  int THistManagerTestSuite::TestFillGroupedHistograms(){
934  THistManager testmgr("testmgr");
935 
936  // Creating 3 groups, 1 with 1D and 1 with 2D histograms, and a third with a subgroup and a TProfile
937  testmgr.CreateTH1("Group1/Test1", "Test 1 Group 1D", 1, 0., 1.);
938  testmgr.CreateTH1("Group1/Test2", "Test 2 Group 1D", 1, 0., 1.);
939  testmgr.CreateTH2("Group2/Test1", "Test 1 Group 2D", 1, 0., 1., 1, 0., 1.);
940  testmgr.CreateTH2("Group2/Test2", "Test 2 Group 2D", 1, 0., 1., 1, 0., 1.);
941  testmgr.CreateTProfile("Group3/Subgroup1/Test1", "Test 1 with subgroup", 1, 0., 1.);
942 
943  for(int i = 0; i < 100; i++){
944  testmgr.FillTH1("Group1/Test1", 0.5);
945  testmgr.FillTH1("Group1/Test2", 0.5);
946  testmgr.FillTH2("Group2/Test1", 0.5, 0.5);
947  testmgr.FillTH2("Group2/Test2", 0.5, 0.5);
948  testmgr.FillProfile("Group3/Subgroup1/Test1", 0.5, 1);
949  }
950 
951  // Evaluate test
952  bool success(true);
953 
954  THashList *currentdir = dynamic_cast<THashList *>(testmgr.GetListOfHistograms()->FindObject("Group1"));
955  if(currentdir){
956  TH1 *test1 = dynamic_cast<TH1 *>(currentdir->FindObject("Test1"));
957  if(test1){
958  if(TMath::Abs(test1->GetBinContent(1) - 100) > DBL_EPSILON){
959  std::cout << "Group1/Test1: Value mismatch: expected 100, found " << test1->GetBinContent(1) << std::endl;
960  success = false;
961  }
962  } else {
963  std::cout << "Not found in Group1: Test1" << std::endl;
964  success = false;
965  }
966  test1 = dynamic_cast<TH1 *>(currentdir->FindObject("Test2"));
967  if(test1){
968  if(TMath::Abs(test1->GetBinContent(1) - 100) > DBL_EPSILON){
969  std::cout << "Group1/Test2: Value mismatch: expected 100, found " << test1->GetBinContent(1) << std::endl;
970  success = false;
971  }
972  } else {
973  std::cout << "Not found in Group1: Test2" << std::endl;
974  success = false;
975  }
976  } else {
977  std::cout << "Not found: Group1" << std::endl;
978  success = false;
979  }
980 
981  currentdir = dynamic_cast<THashList *>(testmgr.GetListOfHistograms()->FindObject("Group2"));
982  if(currentdir){
983  TH2 *test2 = dynamic_cast<TH2 *>(currentdir->FindObject("Test1"));
984  if(test2){
985  if(TMath::Abs(test2->GetBinContent(1,1) - 100) > DBL_EPSILON){
986  std::cout << "Group2/Test1: Value mismatch: expected 100, found " << test2->GetBinContent(1,1) << std::endl;
987  success = false;
988  }
989  } else {
990  std::cout << "Not found in Group2: Test1" << std::endl;
991  success = false;
992  }
993  test2 = dynamic_cast<TH2 *>(currentdir->FindObject("Test2"));
994  if(test2){
995  if(TMath::Abs(test2->GetBinContent(1,1) - 100) > DBL_EPSILON){
996  std::cout << "Group2/Test2: Value mismatch: expected 100, found " << test2->GetBinContent(1,1) << std::endl;
997  success = false;
998  }
999  } else {
1000  std::cout << "Not found in Group2: Test2" << std::endl;
1001  success = false;
1002  }
1003  } else {
1004  std::cout << "Not found: Group2" << std::endl;
1005  success = false;
1006  }
1007 
1008  currentdir = dynamic_cast<THashList *>(testmgr.GetListOfHistograms()->FindObject("Group3"));
1009  if(currentdir){
1010  currentdir = dynamic_cast<THashList *>(currentdir->FindObject("Subgroup1"));
1011  if(currentdir){
1012  TProfile *testprofile = dynamic_cast<TProfile *>(currentdir->FindObject("Test1"));
1013  if(testprofile){
1014  if(TMath::Abs(testprofile->GetBinContent(1) - 1) > DBL_EPSILON){
1015  std::cout << "Group3/Subgroup1/Test1: Value mismatch: expected 1, found " << testprofile->GetBinContent(1) << std::endl;
1016  success = false;
1017  }
1018  } else {
1019  std::cout << "Not found in Group3/Subgroup1: Test1" << std::endl;
1020  success = false;
1021  }
1022  } else {
1023  std::cout << "Not found in Group3: Subgroup1" << std::endl;
1024  success = false;
1025  }
1026  } else {
1027  std::cout << "Not found: Group3" << std::endl;
1028  success = false;
1029  }
1030  return success ? 0 : 1;
1031  }
1032 
1033  int TestRunAll(){
1034  int testresult(0);
1035  THistManagerTestSuite testsuite;
1036 
1037  std::cout << "Running test: Build simple" << std::endl;
1038  testresult += testsuite.TestBuildSimpleHistograms();
1039  std::cout << "Result after test: " << testresult << std::endl;
1040 
1041  std::cout << "Running test: Build grouped" << std::endl;
1042  testresult += testsuite.TestBuildGroupedHistograms();
1043  std::cout << "Result after test: " << testresult << std::endl;
1044 
1045  std::cout << "Running test: Fill Simple" << std::endl;
1046  testresult += testsuite.TestFillSimpleHistograms();
1047  std::cout << "Result after test: " << testresult << std::endl;
1048 
1049  std::cout << "Running test: Fill Grouped" << std::endl;
1050  testresult += testsuite.TestFillGroupedHistograms();
1051  std::cout << "Result after test: " << testresult << std::endl;
1052 
1053  return testresult;
1054  }
1055 
1057  THistManagerTestSuite testsuite;
1058  return testsuite.TestBuildSimpleHistograms();
1059  }
1060 
1062  THistManagerTestSuite testsuite;
1063  return testsuite.TestBuildGroupedHistograms();
1064  }
1065 
1067  THistManagerTestSuite testsuite;
1068  return testsuite.TestFillSimpleHistograms();
1069  }
1070 
1072  THistManagerTestSuite testsuite;
1073  return testsuite.TestFillGroupedHistograms();
1074  }
1075 }
Collection of simple test for the THistManager.
Int_t fNext
Next position in the histmanager.
Definition: THistManager.h:226
iterator & operator=(const iterator &rhs)
THashList * CreateHistoGroup(const char *groupname)
Create a new group of histograms within a parent group.
const Double_t ymax
Definition: AddTaskCFDStar.C:7
double Double_t
Definition: External.C:58
const char * title
Definition: MakeQAPdf.C:27
Definition: External.C:244
bool fIsOwner
Set the ownership.
Definition: THistManager.h:723
Int_t nbinsy
THistManager()
Default constructor.
THashList * FindGroup(const char *dirname) const
Find histogram group.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
void FillTH3(const char *hname, double x, double y, double z, double weight=1., Option_t *opt="")
Fill a 3D histogram within the container.
virtual void CreateBinEdges(TArrayD &binedges) const =0
const THistManager * fkArray
Underlying histmanager to iterate over.
Definition: THistManager.h:224
void SetObject(TObject *const o, const char *group="/")
Set a new group into the container into the parent group.
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
THMIDirection_t fDirection
Direction of the iterator.
Definition: THistManager.h:227
Bool_t operator!=(const iterator &aIter) const
Comparison operator for unequalness.
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
~THistManager()
Destructor.
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
TObject * FindObject(const char *name) const
Find an object inside the container.
int Int_t
Definition: External.C:63
void CreateTProfile(const char *name, const char *title, int nbinsX, double xmin, double xmax, Option_t *opt="")
Create a new TProfile within the container.
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
Definition: External.C:252
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
const Double_t zmin
Definition: External.C:228
Definition: External.C:212
void FillProfile(const char *name, double x, double y, double weight=1.)
THMIDirection_t
Direction for the iteration.
Definition: THistManager.h:128
stl-iterator for the histogram manager
Definition: THistManager.h:115
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
iterator & operator++()
Prefix increment operator.
Int_t nbinsx
TString basename(const TString &path) const
Extracting the basename from a given histogram path.
Collection of tests for the THistManager.
Definition: THistManager.h:766
iterator & operator--()
Prefix decrement operator.
TString histname(const TString &path) const
Extracting the histogram name from a given histogram path.
Definition: External.C:220
TObject * operator*() const
Dereferncing operator.
const Double_t ymin
Definition: AddTaskCFDStar.C:6
Container class for histograms.
Definition: THistManager.h:99
const char Option_t
Definition: External.C:48
const Double_t zmax
const Int_t nbins
bool Bool_t
Definition: External.C:53
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Create a new THnSparse within the container.
THashList * fHistos
List of histograms.
Definition: THistManager.h:722
Definition: External.C:196
TH3 * CreateTH3(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, int nbinsz, double zmin, double zmax, Option_t *opt="")
Create a new TH2 within the container.
Int_t fCurrentPos
Current position of the iterator in the histmanager.
Definition: THistManager.h:225
TDirectoryFile * dir