Clean legent in scan plotting.

This commit is contained in:
salman 2012-11-19 15:02:50 +00:00
parent f8d9526e26
commit c014a44317

View File

@ -42,6 +42,13 @@ void plotRge(TString &names)
Double_t normStop[1000];
Double_t normStopmax[1000];
TString pathname;
int sep;
TString path;
TString name,legtit;
Int_t col;
Int_t color[1000];
for (i=0; i<1000; i++)
@ -55,11 +62,14 @@ void plotRge(TString &names)
color[6] = TColor::kAzure+7;
color[7] = TColor::kOrange+4;
color[8] = TColor::kBlue-7;
TGraph *rge[1000];
TMultiGraph *mg = new TMultiGraph();
TLegend *legend = new TLegend(0.7, 0.7, 0.95, 0.95);
legend->SetFillColor(TColor::GetColor(255,255,255)); // white
tokens = names.Tokenize(" \t,;");
Double_t min = 0, max = 0, xmax = 0, xmin = 0;
@ -123,21 +133,37 @@ void plotRge(TString &names)
str = ostr->GetString() + ", ";
sprintf(cstr, "%.1lf", ostr->GetString().Atof() /1000.0);
str += cstr;
str += " (keV)";
// remove path
sep = str.Last('/');
path = str(0,sep);
name = str(sep+1,str.Length()-sep-1);
// remove comma etc.
sep = name.Last(',');
name = name(0,sep);
// remove extension etc.
sep = name.Last('.');
name = name(0,sep);
// remove ????_ etc.
sep = name.Last('_');
path = name(sep+1);
name = name(sep+2,name.Length()-sep-1);
legtit = "";
legtit += path;
legtit += "=";
legtit += name;
legtit += " (keV)";
cout << endl << legtit << endl ;
rge[i]->SetTitle(str.Data());
rge[i]->SetFillColor(TColor::kWhite);
legend->AddEntry(rge[i], legtit);
delete fileGraph;
}
cout << endl;
mg->Draw("APC");
TLegend *legend = new TLegend(0.7, 0.7, 0.95, 0.95);
legend->SetFillColor(TColor::GetColor(255,255,255)); // white
for (i=0; i<tokens->GetEntries(); i++) {
legend->AddEntry(rge[i]);
}
legend->Draw();