Hi

Sure, here is a typical naive example that I would like to optimize:

```
TH1* Flip(TH1* h, Option_t* option)
{
if( h == NULL) return NULL;
TString opt = option;
opt.ToLower();
TString hname = (TString) h->GetName() + ":" + opt + "-flip";
TH1 *h0 = (TH1*) h->Clone();
TAxis *x1, *x2, *x3;
if(opt == "x") {
x3 = h->GetXaxis();
x1 = h->GetYaxis();
x2 = h->GetZaxis();
} else if(opt == "y") {
x3 = h->GetYaxis();
x1 = h->GetXaxis();
x2 = h->GetZaxis();
} else if(opt == "z") {
x3 = h->GetZaxis();
x1 = h->GetXaxis();
x2 = h->GetYaxis();
} else {
return NULL;
}
int N = h->GetEntries();
for(int x1_i = 1, x1_N = x1->GetNbins(); x1_i <= x1_N; x1_i++) {
for(int x2_i = 1, x2_N = x2->GetNbins(); x2_i <= x2_N; x2_i++) {
double c1 = 0, c2 = 0;
double c1_err = 0, c2_err = 0;
for(int x3_i = 1, x3_N = x3->GetNbins(); x3_i <= x3_N; x3_i++) {
if(opt == "x") {
c1 = h->GetBinContent(x3_i, x1_i, x2_i);
c1_err = h->GetBinError(x3_i, x1_i, x2_i);
c2 = h->GetBinContent(x3->GetNbins()+1-x3_i, x1_i, x2_i);
c2_err = h->GetBinError(x3->GetNbins()+1-x3_i, x1_i, x2_i);
h0->SetBinContent(x3_i, x1_i, x2_i, c2);
h0->SetBinError(x3_i, x1_i, x2_i, c2_err);
h0->SetBinContent(x3->GetNbins()+1-x3_i, x1_i, x2_i, c1);
h0->SetBinError(x3->GetNbins()+1-x3_i, x1_i, x2_i, c1_err);
} else if (opt == "y") {
c1 = h->GetBinContent(x1_i, x3_i, x2_i);
c1_err = h->GetBinError(x1_i, x3_i, x2_i);
c2 = h->GetBinContent(x1_i, x3->GetNbins()+1-x3_i, x2_i);
c2_err = h->GetBinError(x1_i, x3->GetNbins()+1-x3_i, x2_i);
h0->SetBinContent(x1_i, x3_i, x2_i, c2);
h0->SetBinError(x1_i, x3_i, x2_i, c2_err);
h0->SetBinContent(x1_i, x3->GetNbins()+1-x3_i, x2_i, c1);
h0->SetBinError(x1_i, x3->GetNbins()+1-x3_i, x2_i, c1_err);
} else if (opt == "z") {
c1 = h->GetBinContent(x1_i, x2_i, x3_i);
c1_err = h->GetBinError(x1_i, x2_i, x3_i);
c2 = h->GetBinContent(x1_i, x2_i, x3->GetNbins()+1-x3_i);
c2_err = h->GetBinError(x1_i, x2_i, x3->GetNbins()+1-x3_i);
h0->SetBinContent(x1_i, x2_i, x3_i, c2);
h0->SetBinError(x1_i, x2_i, x3_i, c2_err);
h0->SetBinContent(x1_i, x2_i, x3->GetNbins()+1-x3_i, c1);
h0->SetBinError(x1_i, x2_i, x3->GetNbins()+1-x3_i, c1_err);
}
}
}
}
h0->SetEntries(N);
return h0;
}
```