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 *parentgroup =
FindGroup(parentname);
67 THashList *childgroup =
new THashList();
68 childgroup->SetName(
histname(groupname));
69 childgroup->SetOwner();
70 parentgroup->Add(childgroup);
78 if(parent->FindObject(hname)){
79 Fatal(
"THistManager::CreateTH1",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
82 TH1* h =
new TH1D(hname, title, nbins, xmin, xmax);
84 optionstring.ToLower();
85 if(optionstring.Contains(
"s"))
95 if(parent->FindObject(hname)){
96 Fatal(
"THistManager::CreateTH1",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
99 TH1* h =
new TH1D(hname, title, nbins, xbins);
101 optionstring.ToLower();
102 if(optionstring.Contains(
"s"))
112 if(parent->FindObject(hname)){
113 Fatal(
"THistManager::CreateTH1",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
116 TH1* h =
new TH1D(hname, title, xbins.GetSize()-1, xbins.GetArray());
118 optionstring.ToLower();
119 if(optionstring.Contains(
"s"))
129 }
catch(std::exception &e){
130 Fatal(
"THistManager::CreateTH1",
"Exception raised: %s", e.what());
132 return CreateTH1(name, title, myxbins, opt);
139 if(parent->FindObject(hname)){
140 Fatal(
"THistManager::CreateTH2",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
143 TH2* h =
new TH2D(hname, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax);
145 optionstring.ToLower();
146 if(optionstring.Contains(
"s"))
156 if(parent->FindObject(hname)){
157 Fatal(
"THistManager::CreateTH2",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
160 TH2* h =
new TH2D(hname, title, nbinsx, xbins, nbinsy, ybins);
162 optionstring.ToLower();
163 if(optionstring.Contains(
"s"))
173 if(parent->FindObject(hname)){
174 Fatal(
"THistManager::CreateTH2",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
177 TH2* h =
new TH2D(hname, title, xbins.GetSize() - 1, xbins.GetArray(), ybins.GetSize() - 1, ybins.GetArray());
179 optionstring.ToLower();
180 if(optionstring.Contains(
"s"))
190 }
catch (std::exception &e) {
191 Fatal(
"THistManager::CreateTH2 (x-dir)",
"Exception raised: %s", e.what());
195 }
catch (std::exception &e) {
196 Fatal(
"THistManager::CreateTH2 (y-dir)",
"Exception raised: %s", e.what());
199 return CreateTH2(name, title, myxbins, myybins, opt);
202 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) {
206 if(parent->FindObject(hname)){
207 Fatal(
"THistManager::CreateTH3",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
210 TH3* h =
new TH3D(hname, title, nbinsx, xmin, xmax, nbinsy, ymin, ymax, nbinsz, zmin, zmax);
212 optionstring.ToLower();
213 if(optionstring.Contains(
"s"))
223 if(parent->FindObject(hname)){
224 Fatal(
"THistManager::CreateTH3",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
227 TH3* h =
new TH3D(hname, title, nbinsx, xbins, nbinsy, ybins, nbinsz, zbins);
229 optionstring.ToLower();
230 if(optionstring.Contains(
"s"))
240 if(parent->FindObject(hname)){
241 Fatal(
"THistManager::CreateTH3",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
244 TH3* h =
new TH3D(hname, title, xbins.GetSize()-1, xbins.GetArray(), ybins.GetSize()-1, ybins.GetArray(), zbins.GetSize()-1, zbins.GetArray());
246 optionstring.ToLower();
247 if(optionstring.Contains(
"s"))
254 TArrayD myxbins, myybins, myzbins;
257 }
catch (std::exception &e) {
258 Fatal(
"THistManager::CreateTH2 (x-dir)",
"Exception raised: %s", e.what());
262 }
catch (std::exception &e) {
263 Fatal(
"THistManager::CreateTH2 (y-dir)",
"Exception raised: %s", e.what());
267 }
catch (std::exception &e) {
268 Fatal(
"THistManager::CreateTH2 (z-dir)",
"Exception raised: %s", e.what());
271 return CreateTH3(name, title, myxbins, myybins, myzbins);
278 if(parent->FindObject(hname)){
279 Fatal(
"THistManager::CreateTHnSparse",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
282 THnSparse* h =
new THnSparseD(hname, title, ndim, nbins, min, max);
284 optionstring.ToLower();
285 if(optionstring.Contains(
"s"))
295 if(parent->FindObject(hname)){
296 Fatal(
"THistManager::CreateTHnSparse",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
299 TArrayD xmin(ndim), xmax(ndim);
301 for(
int idim = 0; idim < ndim; ++idim){
302 const TAxis &myaxis = *(axes[idim]);
303 nbins[idim] = myaxis.GetNbins();
304 xmin[idim] = myaxis.GetXmin();
305 xmax[idim] = myaxis.GetXmax();
307 THnSparseD *hsparse =
new THnSparseD(hname, title, ndim, nbins.GetArray(), xmin.GetArray(), xmax.GetArray());
308 for(
int id = 0;
id < ndim; ++id)
309 *(hsparse->GetAxis(
id)) = *(axes[
id]);
311 optionstring.ToLower();
312 if(optionstring.Contains(
"s"))
314 parent->Add(hsparse);
322 if(parent->FindObject(hname))
323 Fatal(
"THistManager::CreateTProfile",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
324 TProfile *hist =
new TProfile(hname, title, nbinsX, xmin, xmax, opt);
332 if(parent->FindObject(hname))
333 Fatal(
"THistManager::CreateTHnSparse",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
334 TProfile *hist =
new TProfile(hname, title, nbinsX, xbins, opt);
342 if(parent->FindObject(hname))
343 Fatal(
"THistManager::CreateTHnSparse",
"Object %s already exists in group %s", hname.Data(), dirname.Data());
344 TProfile *hist =
new TProfile(hname.Data(),
title, xbins.GetSize()-1, xbins.GetArray(), opt);
352 }
catch (std::exception &e){
353 Fatal(
"THistManager::CreateProfile",
"Exception raised: %s", e.what());
361 if(parent->FindObject(o->GetName())){
362 Fatal(
"THistManager::SetObject",
"Parent %s does not exist", strcmp(group,
"/") ? group :
"");
365 if(!(dynamic_cast<THnBase *>(o) || dynamic_cast<TH1 *>(o))){
366 Fatal(
"THistManager::SetObject",
"Object %s is not of a histogram type",o->GetName());
376 Fatal(
"THistManager::FillTH1",
"Parnt group %s does not exist", dirname.Data());
379 TH1 *hist =
dynamic_cast<TH1 *
>(parent->FindObject(hname));
381 Fatal(
"THistManager::FillTH1",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
385 if(optionstring.Contains(
"w")){
387 Int_t bin = hist->GetXaxis()->FindBin(x);
389 if(bin != 0 && bin != hist->GetXaxis()->GetNbins())
390 weight = 1./hist->GetXaxis()->GetBinWidth(bin);
392 hist->Fill(x, weight);
399 Fatal(
"THistManager::FillTH1",
"Parnt group %s does not exist", dirname.Data());
402 TH1 *hist =
dynamic_cast<TH1 *
>(parent->FindObject(hname));
404 Fatal(
"THistManager::FillTH1",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
408 if(optionstring.Contains(
"w")){
411 Int_t bin = hist->GetXaxis()->FindBin(label);
413 if(bin != 0 && bin != hist->GetXaxis()->GetNbins())
414 weight = 1./hist->GetXaxis()->GetBinWidth(bin);
416 hist->Fill(label, weight);
423 Fatal(
"THistManager::FillTH2",
"Parent group %s does not exist", dirname.Data());
426 TH2 *hist =
dynamic_cast<TH2 *
>(parent->FindObject(hname));
428 Fatal(
"THistManager::FillTH2",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
432 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
433 if(optstring.Contains(
"wx")){
434 Int_t binx = hist->GetXaxis()->FindBin(x);
435 if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
437 if(optstring.Contains(
"wy")){
438 Int_t biny = hist->GetYaxis()->FindBin(y);
439 if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
441 hist->Fill(x, y, myweight);
448 Fatal(
"THistManager::FillTH2",
"Parent group %s does not exist", dirname.Data());
451 TH2 *hist =
dynamic_cast<TH2 *
>(parent->FindObject(hname));
453 Fatal(
"THistManager::FillTH2",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
457 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
458 if(optstring.Contains(
"wx")){
459 Int_t binx = hist->GetXaxis()->FindBin(point[0]);
460 if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
462 if(optstring.Contains(
"wy")){
463 Int_t biny = hist->GetYaxis()->FindBin(point[1]);
464 if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
466 hist->Fill(point[0], point[1], weight);
473 Fatal(
"THistManager::FillTH3",
"Parent group %s does not exist", dirname.Data());
476 TH3 *hist =
dynamic_cast<TH3 *
>(parent->FindObject(hname));
478 Fatal(
"THistManager::FillTH3",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
482 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
483 if(optstring.Contains(
"wx")){
484 Int_t binx = hist->GetXaxis()->FindBin(x);
485 if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
487 if(optstring.Contains(
"wy")){
488 Int_t biny = hist->GetYaxis()->FindBin(y);
489 if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
491 if(optstring.Contains(
"wz")){
492 Int_t binz = hist->GetZaxis()->FindBin(z);
493 if(binz != 0 && binz != hist->GetZaxis()->GetNbins()) myweight *= 1./hist->GetZaxis()->GetBinWidth(binz);
495 hist->Fill(x, y, z, weight);
502 Fatal(
"THistManager::FillTH3",
"Parent group %s does not exist", dirname.Data());
505 TH3 *hist =
dynamic_cast<TH3 *
>(parent->FindObject(hname));
507 Fatal(
"THistManager::FillTH3",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
511 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
512 if(optstring.Contains(
"wx")){
513 Int_t binx = hist->GetXaxis()->FindBin(point[0]);
514 if(binx != 0 && binx != hist->GetXaxis()->GetNbins()) myweight *= 1./hist->GetXaxis()->GetBinWidth(binx);
516 if(optstring.Contains(
"wy")){
517 Int_t biny = hist->GetYaxis()->FindBin(point[1]);
518 if(biny != 0 && biny != hist->GetYaxis()->GetNbins()) myweight *= 1./hist->GetYaxis()->GetBinWidth(biny);
520 if(optstring.Contains(
"wz")){
521 Int_t binz = hist->GetZaxis()->FindBin(point[2]);
522 if(binz != 0 && binz != hist->GetZaxis()->GetNbins()) myweight *= 1./hist->GetZaxis()->GetBinWidth(binz);
524 hist->Fill(point[0], point[1], point[2], weight);
531 Fatal(
"THistManager::FillTHnSparse",
"Parent group %s does not exist", dirname.Data());
534 THnSparseD *hist =
dynamic_cast<THnSparseD *
>(parent->FindObject(hname));
536 Fatal(
"THistManager::FillTHnSparse",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
540 Double_t myweight = optstring.Contains(
"w") ? 1. : weight;
541 for(
Int_t iaxis = 0; iaxis < hist->GetNdimensions(); iaxis++){
542 std::stringstream weighthandler;
543 weighthandler <<
"w" << iaxis;
544 if(optstring.Contains(weighthandler.str().c_str())){
545 Int_t bin = hist->GetAxis(iaxis)->FindBin(x[iaxis]);
546 if(bin != 0 && bin != hist->GetAxis(iaxis)->GetNbins()) myweight *= hist->GetAxis(iaxis)->GetBinWidth(bin);
550 hist->Fill(x, weight);
557 Fatal(
"THistManager::FillTProfile",
"Parent group %s does not exist", dirname.Data());
558 TProfile *hist =
dynamic_cast<TProfile *
>(parent->FindObject(hname));
560 Fatal(
"THistManager::FillTProfile",
"Histogram %s not found in parent group %s", hname.Data(), dirname.Data());
561 hist->Fill(x, y, weight);
567 if(!parent)
return NULL;
568 return parent->FindObject(hname);
574 if(!parent)
return NULL;
575 return parent->FindObject(hname);
579 if(!strlen(dirname) || !strcmp(dirname,
"/"))
return fHistos;
582 if(parentlist)
return static_cast<THashList *
>(parentlist->FindObject(
histname(dirname)));
587 int index = path.Last(
'/');
588 if(index < 0)
return "";
589 return TString(path(0, index));
593 int index = path.Last(
'/');
594 if(index < 0)
return path;
595 return TString(path(index+1, path.Length() - (index+1)));
612 fkArray(ref.fkArray),
613 fCurrentPos(ref.fCurrentPos),
615 fDirection(ref.fDirection)
633 if(fDirection == kTHMIforward)
647 if(fDirection == kTHMIforward)
662 return fkArray->GetListOfHistograms()->At(fCurrentPos);
673 namespace TestTHistManager {
675 int THistManagerTestSuite::TestBuildSimpleHistograms(){
679 testmgr.
CreateTH1(
"Test1D",
"Test Histogram 1D", 1, 0., 1.);
680 testmgr.
CreateTH2(
"Test2D",
"Test Histogram 2D", 2, 0., 2., 10., 0., 10);
681 testmgr.
CreateTH3(
"Test3D",
"Test Histogram 3D", 3, 2, 6., 10., 0., 10., 50., 0., 50.);
682 int nbins[3] = {3, 3, 3};
double min[3] = {0., 0., 0}, max[3] = {6, 9, 12};
683 testmgr.
CreateTHnSparse(
"TestNSparse",
"Test Histogram NSparse", 3, nbins, min, max);
690 std::cout <<
"Not found: Test1D" << std::endl;
694 std::cout <<
"Not found: Test2D" << std::endl;
698 std::cout <<
"Not found: Test3D" << std::endl;
702 std::cout <<
"Not found: TestNSparse" << std::endl;
706 std::cout <<
"Not found: TestProfile" << std::endl;
710 return found ? 0 : 1;
713 int THistManagerTestSuite::TestBuildGroupedHistograms(){
717 testmgr.
CreateTH1(
"Group1/Test1",
"Test Histogram 1 in group 1", 1, 0., 1.);
718 testmgr.
CreateTH1(
"Group1/Test2",
"Test Histogram 2 in group 1", 1, 0., 1.);
719 testmgr.
CreateTH2(
"Group2/Test1",
"Test Histogram 1 in group 2", 1, 0., 1., 1, 0., 1.);
720 testmgr.
CreateTH2(
"Group2/Test2",
"Test Histogram 2 in group 2", 1, 0., 1., 1, 0., 1.);
721 testmgr.
CreateTH3(
"Group3/Test1",
"Test Histogram 1 in group 3", 1, 0., 1., 1, 0., 1., 1, 0., 1.);
722 testmgr.
CreateTH3(
"Group3/Test2",
"Test Histogram 2 in group 3", 1, 0., 1., 1, 0., 1., 1, 0., 1.);
724 testmgr.
CreateTProfile(
"Group4/Subgroup1/Test1",
"Test histogram for subgroup handling", 1, 0., 1);
729 THashList *currentdir(
nullptr);
730 if(!(currentdir = dynamic_cast<THashList *>(testmgr.
GetListOfHistograms()->FindObject(
"Group1")))){
731 std::cout <<
"Not found: Group1" << std::endl;
734 if(!dynamic_cast<TH1 *>(currentdir->FindObject(
"Test1"))){
735 std::cout <<
"Not found in Group1: Test1" << std::endl;
738 if(!dynamic_cast<TH1 *>(currentdir->FindObject(
"Test2"))){
739 std::cout <<
"Not found in Group1: Test2" << std::endl;
743 if(!(currentdir = dynamic_cast<THashList *>(testmgr.
GetListOfHistograms()->FindObject(
"Group2")))){
744 std::cout <<
"Not found: Group2" << std::endl;
747 if(!dynamic_cast<TH2 *>(currentdir->FindObject(
"Test1"))){
748 std::cout <<
"Not found in Group2: Test1" << std::endl;
751 if(!dynamic_cast<TH2 *>(currentdir->FindObject(
"Test2"))){
752 std::cout <<
"Not found in Group2: Test2" << std::endl;
756 if(!(currentdir = dynamic_cast<THashList *>(testmgr.
GetListOfHistograms()->FindObject(
"Group3")))){
757 std::cout <<
"Not found: Group3" << std::endl;
760 if(!static_cast<TH3 *>(currentdir->FindObject(
"Test1"))){
761 std::cout <<
"Not found in Group3: Test1" << std::endl;
764 if(!static_cast<TH3 *>(currentdir->FindObject(
"Test2"))){
765 std::cout <<
"Not found in Group3: Test2" << std::endl;
769 if(!(currentdir = dynamic_cast<THashList *>(testmgr.
GetListOfHistograms()->FindObject(
"Group4")))){
770 std::cout <<
"Not found: Group4" << std::endl;
773 if(!(currentdir = dynamic_cast<THashList *>(currentdir->FindObject(
"Subgroup1")))){
774 std::cout <<
"Not found in Group4: Subgroup1" << std::endl;
777 if(!dynamic_cast<TH1 *>(currentdir->FindObject(
"Test1"))){
778 std::cout <<
"Not found in Subgroup1: Test1" << std::endl;
783 return found ? 0 : 1;
786 int THistManagerTestSuite::TestFillSimpleHistograms(){
789 testmgr.
CreateTH1(
"Test1",
"Test fill 1D histogram", 1, 0., 1.);
790 testmgr.
CreateTH2(
"Test2",
"Test fill 2D histogram", 1, 0., 1., 1, 0., 1.);
791 testmgr.
CreateTH3(
"Test3",
"Test fill 3D histogram", 1, 0., 1., 1, 0., 1., 1, 0., 1.);
792 int nbins[4] = {1,1,1,1};
double min[4] = {0.,0.,0.,0.}, max[4] = {1.,1.,1.,1.};
793 testmgr.
CreateTHnSparse(
"TestN",
"Test Fill THnSparse", 4, nbins, min, max);
794 testmgr.
CreateTProfile(
"TestProfile",
"Test fill Profile histogram", 1, 0., 1.);
796 double point[4] = {0.5, 0.5, 0.5, 0.5};
797 for(
int i = 0; i < 100; i++){
799 testmgr.
FillTH2(
"Test2", 0.5, 0.5);
800 testmgr.
FillTH3(
"Test3", 0.5, 0.5, 0.5);
811 if(TMath::Abs(test1->GetBinContent(1) - 100) > DBL_EPSILON){
812 std::cout <<
"Test1: Mismatch in values, expected 100, found " << test1->GetBinContent(1) << std::endl;
816 std::cout <<
"Not found: Test1" << std::endl;
822 if(TMath::Abs(test2->GetBinContent(1, 1) - 100) > DBL_EPSILON){
823 std::cout <<
"Test2: Mismatch in values, expected 100, found " << test2->GetBinContent(1,1) << std::endl;
827 std::cout <<
"Not found: Test2" << std::endl;
833 if(TMath::Abs(test3->GetBinContent(1, 1, 1) - 100) > DBL_EPSILON){
834 std::cout <<
"Test3: Mismatch in values, expected 100, found " << test3->GetBinContent(1,1,1) << std::endl;
838 std::cout <<
"Not found: Test3" << std::endl;
842 THnSparse *testN =
dynamic_cast<THnSparse *
>(testmgr.
GetListOfHistograms()->FindObject(
"TestN"));
844 int index[4] = {1,1,1,1};
845 if(TMath::Abs(testN->GetBinContent(index) - 100) > DBL_EPSILON){
846 std::cout <<
"TestN: Mismatch in values, expected 100, found " << testN->GetBinContent(index) << std::endl;
850 std::cout <<
"Not found: TestN" << std::endl;
854 TProfile *testProfile =
dynamic_cast<TProfile *
>(testmgr.
GetListOfHistograms()->FindObject(
"TestProfile"));
856 if(TMath::Abs(testProfile->GetBinContent(1) - 1) > DBL_EPSILON){
857 std::cout <<
"TestProfile: Mismatch in values, expected 1, found " << testProfile->GetBinContent(1) << std::endl;
861 std::cout <<
"Not found: TestProfile" << std::endl;
865 return success ? 0 : 1;
869 int THistManagerTestSuite::TestFillGroupedHistograms(){
873 testmgr.
CreateTH1(
"Group1/Test1",
"Test 1 Group 1D", 1, 0., 1.);
874 testmgr.
CreateTH1(
"Group1/Test2",
"Test 2 Group 1D", 1, 0., 1.);
875 testmgr.
CreateTH2(
"Group2/Test1",
"Test 1 Group 2D", 1, 0., 1., 1, 0., 1.);
876 testmgr.
CreateTH2(
"Group2/Test2",
"Test 2 Group 2D", 1, 0., 1., 1, 0., 1.);
877 testmgr.
CreateTProfile(
"Group3/Subgroup1/Test1",
"Test 1 with subgroup", 1, 0., 1.);
879 for(
int i = 0; i < 100; i++){
880 testmgr.
FillTH1(
"Group1/Test1", 0.5);
881 testmgr.
FillTH1(
"Group1/Test2", 0.5);
882 testmgr.
FillTH2(
"Group2/Test1", 0.5, 0.5);
883 testmgr.
FillTH2(
"Group2/Test2", 0.5, 0.5);
884 testmgr.
FillProfile(
"Group3/Subgroup1/Test1", 0.5, 1);
890 THashList *currentdir =
dynamic_cast<THashList *
>(testmgr.
GetListOfHistograms()->FindObject(
"Group1"));
892 TH1 *test1 =
dynamic_cast<TH1 *
>(currentdir->FindObject(
"Test1"));
894 if(TMath::Abs(test1->GetBinContent(1) - 100) > DBL_EPSILON){
895 std::cout <<
"Group1/Test1: Value mismatch: expected 100, found " << test1->GetBinContent(1) << std::endl;
899 std::cout <<
"Not found in Group1: Test1" << std::endl;
902 test1 =
dynamic_cast<TH1 *
>(currentdir->FindObject(
"Test2"));
904 if(TMath::Abs(test1->GetBinContent(1) - 100) > DBL_EPSILON){
905 std::cout <<
"Group1/Test2: Value mismatch: expected 100, found " << test1->GetBinContent(1) << std::endl;
909 std::cout <<
"Not found in Group1: Test2" << std::endl;
913 std::cout <<
"Not found: Group1" << std::endl;
917 currentdir =
dynamic_cast<THashList *
>(testmgr.
GetListOfHistograms()->FindObject(
"Group2"));
919 TH2 *test2 =
dynamic_cast<TH2 *
>(currentdir->FindObject(
"Test1"));
921 if(TMath::Abs(test2->GetBinContent(1,1) - 100) > DBL_EPSILON){
922 std::cout <<
"Group2/Test1: Value mismatch: expected 100, found " << test2->GetBinContent(1,1) << std::endl;
926 std::cout <<
"Not found in Group2: Test1" << std::endl;
929 test2 =
dynamic_cast<TH2 *
>(currentdir->FindObject(
"Test2"));
931 if(TMath::Abs(test2->GetBinContent(1,1) - 100) > DBL_EPSILON){
932 std::cout <<
"Group2/Test2: Value mismatch: expected 100, found " << test2->GetBinContent(1,1) << std::endl;
936 std::cout <<
"Not found in Group2: Test2" << std::endl;
940 std::cout <<
"Not found: Group2" << std::endl;
944 currentdir =
dynamic_cast<THashList *
>(testmgr.
GetListOfHistograms()->FindObject(
"Group3"));
946 currentdir =
dynamic_cast<THashList *
>(currentdir->FindObject(
"Subgroup1"));
948 TProfile *testprofile =
dynamic_cast<TProfile *
>(currentdir->FindObject(
"Test1"));
950 if(TMath::Abs(testprofile->GetBinContent(1) - 1) > DBL_EPSILON){
951 std::cout <<
"Group3/Subgroup1/Test1: Value mismatch: expected 1, found " << testprofile->GetBinContent(1) << std::endl;
955 std::cout <<
"Not found in Group3/Subgroup1: Test1" << std::endl;
959 std::cout <<
"Not found in Group3: Subgroup1" << std::endl;
963 std::cout <<
"Not found: Group3" << std::endl;
966 return success ? 0 : 1;
973 std::cout <<
"Running test: Build simple" << std::endl;
975 std::cout <<
"Result after test: " << testresult << std::endl;
977 std::cout <<
"Running test: Build grouped" << std::endl;
979 std::cout <<
"Result after test: " << testresult << std::endl;
981 std::cout <<
"Running test: Fill Simple" << std::endl;
983 std::cout <<
"Result after test: " << testresult << std::endl;
985 std::cout <<
"Running test: Fill Grouped" << std::endl;
987 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()