Hi everybody,
I have a problem, but as I am not sure, what the problem is, I can’t be too precise. I have several TGraphErrors which are shown as expected when I draw them. However as soon as I combine them in a TMultiGraph, the canvas is empty. What confuses me is, that I have done this quite often and never had any problems. Therefor I do not not what’s wrong now. This is my code:
TGraphErrors* Changer(TH1* Hist, TString Name, int n,Double_t Shift){
int LowBin=Hist->FindBin(1615);
int UpBin=Hist->FindBin(2010);
TGraphErrors* Result =new TGraphErrors(UpBin-LowBin+1);
for (int i=LowBin;i<UpBin+1;i++) {
Result->SetPoint(i, Hist->GetBinCenter(i)+Shift, Hist->GetBinContent(i));
Result->SetPointError(i, 0, Hist->GetBinError(i));
}
Result->SetTitle(Name);
Result->SetMaximum(0.35);
return Result;
}
void AngleBinnedShower()
{
TFile *f1= TFile::Open("AngleBinned/CrossSection_JustK_SW_3Tagger_Final_AL.root");
TFile *f2= TFile::Open("AngleBinned/CrossSection_JustK_SW_3Tagger_Final_AM.root");
TFile *f3= TFile::Open("AngleBinned/CrossSection_JustK_SW_3Tagger_Final_AH.root");
TH1 *Low = (TH1*) f1->FindObjectAny("CrossSection");
TH1 *Mid = (TH1*) f2->FindObjectAny("CrossSection");
TH1 *High = (TH1*) f3->FindObjectAny("CrossSection");
TGraphErrors* LGr = Changer(Low,"Low",Low->GetNbinsX(),-2);
TGraphErrors* MGr = Changer(Mid,"Mid",Mid->GetNbinsX(),0);
TGraphErrors* HGr = Changer(High,"High",High->GetNbinsX(),2);
TCanvas *can = new TCanvas("c","c",800,400);
TMultiGraph *mg = new TMultiGraph();
Int_t palette[6] = {597,2,3,4,6,900};
Int_t marker[6] = {20,21,22,23,29,33};
LGr->SetMarkerStyle(marker[0]);
LGr->SetMarkerColor(palette[0]);
LGr->SetLineColor(palette[0]);
LGr->SetMarkerSize(1.8);
mg->Add(LGr,"AP");
MGr->SetMarkerStyle(marker[1]);
MGr->SetMarkerColor(palette[1]);
MGr->SetLineColor(palette[1]);
MGr->SetMarkerSize(1.8);
mg->Add(MGr,"AP");
HGr->SetMarkerStyle(marker[2]);
HGr->SetMarkerColor(palette[2]);
HGr->SetLineColor(palette[2]);
HGr->SetMarkerSize(1.8);
mg->Add(HGr,"AP");
mg->GetXaxis()->SetTitle("#gamma Energy [MeV]");
mg->GetYaxis()->SetTitle("#frac{d#sigma}{d#Omega} [#mub]");
mg->Draw("AP");
}
Maybe someone can spot my mistake?
Thanks,
Emil