27 #include <THnSparse.h>
28 #include <THashList.h>
30 #include <TObjArray.h>
31 #include <TObjString.h>
50 TNamed(name, Form(
"Histogram container %s", name)),
55 fHistos->SetName(Form(
"histos%s", name));
65 THashList *foundgroup =
FindGroup(groupname);
71 THashList *parentgroup =
FindGroup(parentname);
73 THashList *childgroup =
new THashList();
74 childgroup->SetName(
histname(groupname));
75 childgroup->SetOwner();
76 parentgroup->Add(childgroup);
84 if(parent->FindObject(hname)){
85 Fatal(
"THistManager::CreateTH1",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
88 TH1* h =
new TH1D(hname, title, nbins, xmin, xmax);
90 optionstring.ToLower();
91 if(optionstring.Contains(
"s"))
101 if(parent->FindObject(hname)){
102 Fatal(
"THistManager::CreateTH1",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
105 TH1* h =
new TH1D(hname, title, nbins, xbins);
107 optionstring.ToLower();
108 if(optionstring.Contains(
"s"))
118 if(parent->FindObject(hname)){
119 Fatal(
"THistManager::CreateTH1",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
122 TH1* h =
new TH1D(hname, title, xbins.GetSize()-1, xbins.GetArray());
124 optionstring.ToLower();
125 if(optionstring.Contains(
"s"))
135 }
catch(std::exception &e){
136 Fatal(
"THistManager::CreateTH1",
"Exception raised: %s", e.what());
138 return CreateTH1(name, title, myxbins, opt);
145 if(parent->FindObject(hname)){
146 Fatal(
"THistManager::CreateTH2",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
149 TH2* h =
new TH2D(hname, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax);
151 optionstring.ToLower();
152 if(optionstring.Contains(
"s"))
162 if(parent->FindObject(hname)){
163 Fatal(
"THistManager::CreateTH2",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
166 TH2* h =
new TH2D(hname, title, nbinsx, xbins, nbinsy, ybins);
168 optionstring.ToLower();
169 if(optionstring.Contains(
"s"))
179 if(parent->FindObject(hname)){
180 Fatal(
"THistManager::CreateTH2",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
183 TH2* h =
new TH2D(hname, title, xbins.GetSize() - 1, xbins.GetArray(), ybins.GetSize() - 1, ybins.GetArray());
185 optionstring.ToLower();
186 if(optionstring.Contains(
"s"))
196 }
catch (std::exception &e) {
197 Fatal(
"THistManager::CreateTH2 (x-dir)",
"Exception raised: %s", e.what());
201 }
catch (std::exception &e) {
202 Fatal(
"THistManager::CreateTH2 (y-dir)",
"Exception raised: %s", e.what());
205 return CreateTH2(name, title, myxbins, myybins, opt);
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) {
212 if(parent->FindObject(hname)){
213 Fatal(
"THistManager::CreateTH3",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
216 TH3* h =
new TH3D(hname, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax, nbinsz, zmin, zmax);
218 optionstring.ToLower();
219 if(optionstring.Contains(
"s"))
229 if(parent->FindObject(hname)){
230 Fatal(
"THistManager::CreateTH3",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
233 TH3* h =
new TH3D(hname, title, nbinsx, xbins, nbinsy, ybins, nbinsz, zbins);
235 optionstring.ToLower();
236 if(optionstring.Contains(
"s"))
246 if(parent->FindObject(hname)){
247 Fatal(
"THistManager::CreateTH3",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
250 TH3* h =
new TH3D(hname, title, xbins.GetSize()-1, xbins.GetArray(), ybins.GetSize()-1, ybins.GetArray(), zbins.GetSize()-1, zbins.GetArray());
252 optionstring.ToLower();
253 if(optionstring.Contains(
"s"))
260 TArrayD myxbins, myybins, myzbins;
263 }
catch (std::exception &e) {
264 Fatal(
"THistManager::CreateTH2 (x-dir)",
"Exception raised: %s", e.what());
268 }
catch (std::exception &e) {
269 Fatal(
"THistManager::CreateTH2 (y-dir)",
"Exception raised: %s", e.what());
273 }
catch (std::exception &e) {
274 Fatal(
"THistManager::CreateTH2 (z-dir)",
"Exception raised: %s", e.what());
277 return CreateTH3(name, title, myxbins, myybins, myzbins);
284 if(parent->FindObject(hname)){
285 Fatal(
"THistManager::CreateTHnSparse",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
288 THnSparse* h =
new THnSparseD(hname, title, ndim, nbins, min, max);
290 optionstring.ToLower();
291 if(optionstring.Contains(
"s"))
301 if(parent->FindObject(hname)){
302 Fatal(
"THistManager::CreateTHnSparse",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
305 TArrayD xmin(ndim), xmax(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();
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]);
317 optionstring.ToLower();
318 if(optionstring.Contains(
"s"))
320 parent->Add(hsparse);
328 if(parent->FindObject(hname))
329 Fatal(
"THistManager::CreateTProfile",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
330 TProfile *hist =
new TProfile(hname, title, nbinsX, xmin, xmax, opt);
338 if(parent->FindObject(hname))
339 Fatal(
"THistManager::CreateTHnSparse",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
340 TProfile *hist =
new TProfile(hname, title, nbinsX, xbins, opt);
348 if(parent->FindObject(hname))
349 Fatal(
"THistManager::CreateTHnSparse",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
350 TProfile *hist =
new TProfile(hname.Data(),
title, xbins.GetSize()-1, xbins.GetArray(), opt);
358 }
catch (std::exception &e){
359 Fatal(
"THistManager::CreateProfile",
"Exception raised: %s", e.what());
367 if(parent->FindObject(o->GetName())){
368 Fatal(
"THistManager::SetObject",
"Parent %s does not exist", strcmp(group,
"/") ? group :
"");
371 if(!(dynamic_cast<THnBase *>(o) || dynamic_cast<TH1 *>(o))){
372 Fatal(
"THistManager::SetObject",
"Object %s is not of a histogram type",o->GetName());
382 Fatal(
"THistManager::FillTH1",
"Parnt group %s does not exist", dirname.Data());
385 TH1 *hist =
dynamic_cast<TH1 *
>(parent->FindObject(hname));
387 Fatal(
"THistManager::FillTH1",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
391 if(optionstring.Contains(
"w")){
393 Int_t bin = hist->GetXaxis()->FindBin(x);
395 if(bin != 0 && bin != hist->GetXaxis()->GetNbins())
396 weight = 1./hist->GetXaxis()->GetBinWidth(bin);
398 hist->Fill(x, weight);
405 Fatal(
"THistManager::FillTH1",
"Parnt group %s does not exist", dirname.Data());
408 TH1 *hist =
dynamic_cast<TH1 *
>(parent->FindObject(hname));
410 Fatal(
"THistManager::FillTH1",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
414 if(optionstring.Contains(
"w")){
417 Int_t bin = hist->GetXaxis()->FindBin(label);
419 if(bin != 0 && bin != hist->GetXaxis()->GetNbins())
420 weight = 1./hist->GetXaxis()->GetBinWidth(bin);
422 hist->Fill(label, weight);
429 Fatal(
"THistManager::FillTH2",
"Parent group %s does not exist", dirname.Data());
432 TH2 *hist =
dynamic_cast<TH2 *
>(parent->FindObject(hname));
434 Fatal(
"THistManager::FillTH2",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
438 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
439 if(optstring.Contains(
"wx")){
440 Int_t binx = hist->GetXaxis()->FindBin(x);
441 if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
443 if(optstring.Contains(
"wy")){
444 Int_t biny = hist->GetYaxis()->FindBin(y);
445 if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
447 hist->Fill(x, y, myweight);
454 Fatal(
"THistManager::FillTH2",
"Parent group %s does not exist", dirname.Data());
457 TH2 *hist =
dynamic_cast<TH2 *
>(parent->FindObject(hname));
459 Fatal(
"THistManager::FillTH2",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
463 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
464 if(optstring.Contains(
"wx")){
465 Int_t binx = hist->GetXaxis()->FindBin(point[0]);
466 if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
468 if(optstring.Contains(
"wy")){
469 Int_t biny = hist->GetYaxis()->FindBin(point[1]);
470 if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
472 hist->Fill(point[0], point[1], weight);
479 Fatal(
"THistManager::FillTH3",
"Parent group %s does not exist", dirname.Data());
482 TH3 *hist =
dynamic_cast<TH3 *
>(parent->FindObject(hname));
484 Fatal(
"THistManager::FillTH3",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
488 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
489 if(optstring.Contains(
"wx")){
490 Int_t binx = hist->GetXaxis()->FindBin(x);
491 if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
493 if(optstring.Contains(
"wy")){
494 Int_t biny = hist->GetYaxis()->FindBin(y);
495 if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
497 if(optstring.Contains(
"wz")){
498 Int_t binz = hist->GetZaxis()->FindBin(z);
499 if(binz != 0 && binz != hist->GetZaxis()->GetNbins()) myweight *= 1./hist->GetZaxis()->GetBinWidth(binz);
501 hist->Fill(x, y, z, weight);
508 Fatal(
"THistManager::FillTH3",
"Parent group %s does not exist", dirname.Data());
511 TH3 *hist =
dynamic_cast<TH3 *
>(parent->FindObject(hname));
513 Fatal(
"THistManager::FillTH3",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
517 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
518 if(optstring.Contains(
"wx")){
519 Int_t binx = hist->GetXaxis()->FindBin(point[0]);
520 if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
522 if(optstring.Contains(
"wy")){
523 Int_t biny = hist->GetYaxis()->FindBin(point[1]);
524 if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
526 if(optstring.Contains(
"wz")){
527 Int_t binz = hist->GetZaxis()->FindBin(point[2]);
528 if(binz != 0 && binz != hist->GetZaxis()->GetNbins()) myweight *= 1./hist->GetZaxis()->GetBinWidth(binz);
530 hist->Fill(point[0], point[1], point[2], weight);
537 Fatal(
"THistManager::FillTHnSparse",
"Parent group %s does not exist", dirname.Data());
540 THnSparseD *hist =
dynamic_cast<THnSparseD *
>(parent->FindObject(hname));
542 Fatal(
"THistManager::FillTHnSparse",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
546 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
547 for(
Int_t iaxis = 0; iaxis < hist->GetNdimensions(); iaxis++){
548 std::stringstream weighthandler;
549 weighthandler <<
"w" << iaxis;
550 if(optstring.Contains(weighthandler.str().c_str())){
551 Int_t bin = hist->GetAxis(iaxis)->FindBin(x[iaxis]);
552 if(bin != 0 && bin != hist->GetAxis(iaxis)->GetNbins()) myweight *= hist->GetAxis(iaxis)->GetBinWidth(bin);
556 hist->Fill(x, weight);
563 Fatal(
"THistManager::FillTProfile",
"Parent group %s does not exist", dirname.Data());
564 TProfile *hist =
dynamic_cast<TProfile *
>(parent->FindObject(hname));
566 Fatal(
"THistManager::FillTProfile",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
567 hist->Fill(x, y, weight);
573 if(!parent)
return NULL;
574 return parent->FindObject(hname);
580 if(!parent)
return NULL;
581 return parent->FindObject(hname);
585 if(!strlen(dirname) || !strcmp(dirname,
"/"))
return fHistos;
588 if(parentlist)
return static_cast<THashList *
>(parentlist->FindObject(
histname(dirname)));
593 int index = path.Last(
'/');
594 if(index < 0)
return "";
595 return TString(path(0, index));
599 int index = path.Last(
'/');
600 if(index < 0)
return path;
601 return TString(path(index+1, path.Length() - (index+1)));
618 fkArray(ref.fkArray),
619 fCurrentPos(ref.fCurrentPos),
621 fDirection(ref.fDirection)
639 if(fDirection == kTHMIforward)
653 if(fDirection == kTHMIforward)
668 return fkArray->GetListOfHistograms()->At(fCurrentPos);
679 namespace TestTHistManager {
681 int THistManagerTestSuite::TestBuildSimpleHistograms(){
685 testmgr.
CreateTH1(
"Test1D",
"Test Histogram 1D", 1, 0., 1.);
686 testmgr.
CreateTH2(
"Test2D",
"Test Histogram 2D", 2, 0., 2., 10., 0., 10);
687 testmgr.
CreateTH3(
"Test3D",
"Test Histogram 3D", 3, 2, 6., 10., 0., 10., 50., 0., 50.);
688 int nbins[3] = {3, 3, 3};
double min[3] = {0., 0., 0}, max[3] = {6, 9, 12};
689 testmgr.
CreateTHnSparse(
"TestNSparse",
"Test Histogram NSparse", 3, nbins, min, max);
696 std::cout <<
"Not found: Test1D" << std::endl;
700 std::cout <<
"Not found: Test2D" << std::endl;
704 std::cout <<
"Not found: Test3D" << std::endl;
708 std::cout <<
"Not found: TestNSparse" << std::endl;
712 std::cout <<
"Not found: TestProfile" << std::endl;
716 return found ? 0 : 1;
719 int THistManagerTestSuite::TestBuildGroupedHistograms(){
723 testmgr.
CreateTH1(
"Group1/Test1",
"Test Histogram 1 in group 1", 1, 0., 1.);
724 testmgr.
CreateTH1(
"Group1/Test2",
"Test Histogram 2 in group 1", 1, 0., 1.);
725 testmgr.
CreateTH2(
"Group2/Test1",
"Test Histogram 1 in group 2", 1, 0., 1., 1, 0., 1.);
726 testmgr.
CreateTH2(
"Group2/Test2",
"Test Histogram 2 in group 2", 1, 0., 1., 1, 0., 1.);
727 testmgr.
CreateTH3(
"Group3/Test1",
"Test Histogram 1 in group 3", 1, 0., 1., 1, 0., 1., 1, 0., 1.);
728 testmgr.
CreateTH3(
"Group3/Test2",
"Test Histogram 2 in group 3", 1, 0., 1., 1, 0., 1., 1, 0., 1.);
730 testmgr.
CreateTProfile(
"Group4/Subgroup1/Test1",
"Test histogram for subgroup handling", 1, 0., 1);
735 THashList *currentdir(
nullptr);
736 if(!(currentdir = dynamic_cast<THashList *>(testmgr.
GetListOfHistograms()->FindObject(
"Group1")))){
737 std::cout <<
"Not found: Group1" << std::endl;
740 if(!dynamic_cast<TH1 *>(currentdir->FindObject(
"Test1"))){
741 std::cout <<
"Not found in Group1: Test1" << std::endl;
744 if(!dynamic_cast<TH1 *>(currentdir->FindObject(
"Test2"))){
745 std::cout <<
"Not found in Group1: Test2" << std::endl;
749 if(!(currentdir = dynamic_cast<THashList *>(testmgr.
GetListOfHistograms()->FindObject(
"Group2")))){
750 std::cout <<
"Not found: Group2" << std::endl;
753 if(!dynamic_cast<TH2 *>(currentdir->FindObject(
"Test1"))){
754 std::cout <<
"Not found in Group2: Test1" << std::endl;
757 if(!dynamic_cast<TH2 *>(currentdir->FindObject(
"Test2"))){
758 std::cout <<
"Not found in Group2: Test2" << std::endl;
762 if(!(currentdir = dynamic_cast<THashList *>(testmgr.
GetListOfHistograms()->FindObject(
"Group3")))){
763 std::cout <<
"Not found: Group3" << std::endl;
766 if(!static_cast<TH3 *>(currentdir->FindObject(
"Test1"))){
767 std::cout <<
"Not found in Group3: Test1" << std::endl;
770 if(!static_cast<TH3 *>(currentdir->FindObject(
"Test2"))){
771 std::cout <<
"Not found in Group3: Test2" << std::endl;
775 if(!(currentdir = dynamic_cast<THashList *>(testmgr.
GetListOfHistograms()->FindObject(
"Group4")))){
776 std::cout <<
"Not found: Group4" << std::endl;
779 if(!(currentdir = dynamic_cast<THashList *>(currentdir->FindObject(
"Subgroup1")))){
780 std::cout <<
"Not found in Group4: Subgroup1" << std::endl;
783 if(!dynamic_cast<TH1 *>(currentdir->FindObject(
"Test1"))){
784 std::cout <<
"Not found in Subgroup1: Test1" << std::endl;
789 return found ? 0 : 1;
792 int THistManagerTestSuite::TestFillSimpleHistograms(){
795 testmgr.
CreateTH1(
"Test1",
"Test fill 1D histogram", 1, 0., 1.);
796 testmgr.
CreateTH2(
"Test2",
"Test fill 2D histogram", 1, 0., 1., 1, 0., 1.);
797 testmgr.
CreateTH3(
"Test3",
"Test fill 3D histogram", 1, 0., 1., 1, 0., 1., 1, 0., 1.);
798 int nbins[4] = {1,1,1,1};
double min[4] = {0.,0.,0.,0.}, max[4] = {1.,1.,1.,1.};
799 testmgr.
CreateTHnSparse(
"TestN",
"Test Fill THnSparse", 4, nbins, min, max);
800 testmgr.
CreateTProfile(
"TestProfile",
"Test fill Profile histogram", 1, 0., 1.);
802 double point[4] = {0.5, 0.5, 0.5, 0.5};
803 for(
int i = 0; i < 100; i++){
805 testmgr.
FillTH2(
"Test2", 0.5, 0.5);
806 testmgr.
FillTH3(
"Test3", 0.5, 0.5, 0.5);
817 if(TMath::Abs(test1->GetBinContent(1) - 100) > DBL_EPSILON){
818 std::cout <<
"Test1: Mismatch in values, expected 100, found " << test1->GetBinContent(1) << std::endl;
822 std::cout <<
"Not found: Test1" << std::endl;
828 if(TMath::Abs(test2->GetBinContent(1, 1) - 100) > DBL_EPSILON){
829 std::cout <<
"Test2: Mismatch in values, expected 100, found " << test2->GetBinContent(1,1) << std::endl;
833 std::cout <<
"Not found: Test2" << std::endl;
839 if(TMath::Abs(test3->GetBinContent(1, 1, 1) - 100) > DBL_EPSILON){
840 std::cout <<
"Test3: Mismatch in values, expected 100, found " << test3->GetBinContent(1,1,1) << std::endl;
844 std::cout <<
"Not found: Test3" << std::endl;
848 THnSparse *testN =
dynamic_cast<THnSparse *
>(testmgr.
GetListOfHistograms()->FindObject(
"TestN"));
850 int index[4] = {1,1,1,1};
851 if(TMath::Abs(testN->GetBinContent(index) - 100) > DBL_EPSILON){
852 std::cout <<
"TestN: Mismatch in values, expected 100, found " << testN->GetBinContent(index) << std::endl;
856 std::cout <<
"Not found: TestN" << std::endl;
860 TProfile *testProfile =
dynamic_cast<TProfile *
>(testmgr.
GetListOfHistograms()->FindObject(
"TestProfile"));
862 if(TMath::Abs(testProfile->GetBinContent(1) - 1) > DBL_EPSILON){
863 std::cout <<
"TestProfile: Mismatch in values, expected 1, found " << testProfile->GetBinContent(1) << std::endl;
867 std::cout <<
"Not found: TestProfile" << std::endl;
871 return success ? 0 : 1;
875 int THistManagerTestSuite::TestFillGroupedHistograms(){
879 testmgr.
CreateTH1(
"Group1/Test1",
"Test 1 Group 1D", 1, 0., 1.);
880 testmgr.
CreateTH1(
"Group1/Test2",
"Test 2 Group 1D", 1, 0., 1.);
881 testmgr.
CreateTH2(
"Group2/Test1",
"Test 1 Group 2D", 1, 0., 1., 1, 0., 1.);
882 testmgr.
CreateTH2(
"Group2/Test2",
"Test 2 Group 2D", 1, 0., 1., 1, 0., 1.);
883 testmgr.
CreateTProfile(
"Group3/Subgroup1/Test1",
"Test 1 with subgroup", 1, 0., 1.);
885 for(
int i = 0; i < 100; i++){
886 testmgr.
FillTH1(
"Group1/Test1", 0.5);
887 testmgr.
FillTH1(
"Group1/Test2", 0.5);
888 testmgr.
FillTH2(
"Group2/Test1", 0.5, 0.5);
889 testmgr.
FillTH2(
"Group2/Test2", 0.5, 0.5);
890 testmgr.
FillProfile(
"Group3/Subgroup1/Test1", 0.5, 1);
896 THashList *currentdir =
dynamic_cast<THashList *
>(testmgr.
GetListOfHistograms()->FindObject(
"Group1"));
898 TH1 *test1 =
dynamic_cast<TH1 *
>(currentdir->FindObject(
"Test1"));
900 if(TMath::Abs(test1->GetBinContent(1) - 100) > DBL_EPSILON){
901 std::cout <<
"Group1/Test1: Value mismatch: expected 100, found " << test1->GetBinContent(1) << std::endl;
905 std::cout <<
"Not found in Group1: Test1" << std::endl;
908 test1 =
dynamic_cast<TH1 *
>(currentdir->FindObject(
"Test2"));
910 if(TMath::Abs(test1->GetBinContent(1) - 100) > DBL_EPSILON){
911 std::cout <<
"Group1/Test2: Value mismatch: expected 100, found " << test1->GetBinContent(1) << std::endl;
915 std::cout <<
"Not found in Group1: Test2" << std::endl;
919 std::cout <<
"Not found: Group1" << std::endl;
923 currentdir =
dynamic_cast<THashList *
>(testmgr.
GetListOfHistograms()->FindObject(
"Group2"));
925 TH2 *test2 =
dynamic_cast<TH2 *
>(currentdir->FindObject(
"Test1"));
927 if(TMath::Abs(test2->GetBinContent(1,1) - 100) > DBL_EPSILON){
928 std::cout <<
"Group2/Test1: Value mismatch: expected 100, found " << test2->GetBinContent(1,1) << std::endl;
932 std::cout <<
"Not found in Group2: Test1" << std::endl;
935 test2 =
dynamic_cast<TH2 *
>(currentdir->FindObject(
"Test2"));
937 if(TMath::Abs(test2->GetBinContent(1,1) - 100) > DBL_EPSILON){
938 std::cout <<
"Group2/Test2: Value mismatch: expected 100, found " << test2->GetBinContent(1,1) << std::endl;
942 std::cout <<
"Not found in Group2: Test2" << std::endl;
946 std::cout <<
"Not found: Group2" << std::endl;
950 currentdir =
dynamic_cast<THashList *
>(testmgr.
GetListOfHistograms()->FindObject(
"Group3"));
952 currentdir =
dynamic_cast<THashList *
>(currentdir->FindObject(
"Subgroup1"));
954 TProfile *testprofile =
dynamic_cast<TProfile *
>(currentdir->FindObject(
"Test1"));
956 if(TMath::Abs(testprofile->GetBinContent(1) - 1) > DBL_EPSILON){
957 std::cout <<
"Group3/Subgroup1/Test1: Value mismatch: expected 1, found " << testprofile->GetBinContent(1) << std::endl;
961 std::cout <<
"Not found in Group3/Subgroup1: Test1" << std::endl;
965 std::cout <<
"Not found in Group3: Subgroup1" << std::endl;
969 std::cout <<
"Not found: Group3" << std::endl;
972 return success ? 0 : 1;
979 std::cout <<
"Running test: Build simple" << std::endl;
981 std::cout <<
"Result after test: " << testresult << std::endl;
983 std::cout <<
"Running test: Build grouped" << std::endl;
985 std::cout <<
"Result after test: " << testresult << std::endl;
987 std::cout <<
"Running test: Fill Simple" << std::endl;
989 std::cout <<
"Result after test: " << testresult << std::endl;
991 std::cout <<
"Running test: Fill Grouped" << std::endl;
993 std::cout <<
"Result after test: " << testresult << std::endl;
iterator & operator=(const iterator &rhs)
THashList * CreateHistoGroup(const char *groupname)
bool fIsOwner
Set the ownership.
THashList * FindGroup(const char *dirname) const
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
void FillTH3(const char *hname, double x, double y, double z, double weight=1., Option_t *opt="")
virtual void CreateBinEdges(TArrayD &binedges) const =0
const THistManager * fkArray
void SetObject(TObject *const o, const char *group="/")
Interface for binnings used by the histogram handler.
THMIDirection_t fDirection
Bool_t operator!=(const iterator &aIter) const
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
TObject * FindObject(const char *name) const
int TestBuildSimpleHistograms()
void CreateTProfile(const char *name, const char *title, int nbinsX, double xmin, double xmax, Option_t *opt="")
THashList * GetListOfHistograms() const
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
void FillProfile(const char *name, double x, double y, double weight=1.)
int TestBuildGroupedHistograms()
THMIDirection_t
Direction for the iteration.
int TestFillGroupedHistograms()
stl-iterator for the histogram manager
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
int TestRunBuildGrouped()
TString basename(const TString &path) const
Collection of tests for the THistManager.
TString histname(const TString &path) const
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TObject * operator*() const
Container class for histograms.
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
THashList * fHistos
List of histograms.
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="")
int TestFillSimpleHistograms()