#include #include using namespace std; int main() { // Creat 3D histo and set all entries equal to 1 TH3F* testhistogram = new TH3F("testhistogram","Test Histogram",10,0,1,10,0,1,10,0,1); for (int i = 1; i<=10; i++) { for (int j = 1; j<=10; j++) { for (int k = 1; k<=10; k++) { testhistogram->SetBinContent(i,j,k,1); } } } //Project out a single (y,z) column testhistogram->GetXaxis()->SetRange(1,10); testhistogram->GetYaxis()->SetRange(3,3); testhistogram->GetZaxis()->SetRange(3,3); TH1F* projx = (TH1F*)testhistogram->Project3D("xe"); //Project out a single (x,z) column testhistogram->GetXaxis()->SetRange(3,3); testhistogram->GetYaxis()->SetRange(1,10); testhistogram->GetZaxis()->SetRange(3,3); TH1F* projy = (TH1F*)testhistogram->Project3D("ye"); testhistogram->GetXaxis()->SetRange(3,3); testhistogram->GetYaxis()->SetRange(3,3); testhistogram->GetZaxis()->SetRange(1,10); TH1F* projz = (TH1F*)testhistogram->Project3D("ze"); cout << "max of projx = " << projx->GetMaximum() << "\nmax of projy = " << projy->GetMaximum() << "\nmax of projz = " << projz->GetMaximum() << "\n"; }