Improved plotting of fractions from energy scans.

This commit is contained in:
salman 2012-01-12 12:53:16 +00:00
parent 496806a0ad
commit a6acae01c5
2 changed files with 77 additions and 27 deletions

View File

@ -17,7 +17,7 @@ void plotFrc(char *FileName)
TString line, label, treeLabel;
TString rootFileName;
TObjArray *token;
TObjArray *token,*labels;
TObjString *strtoken;
Int_t nPars = 0;
Int_t ntokens = 0;
@ -25,6 +25,7 @@ void plotFrc(char *FileName)
Int_t nline=0;
Ssiz_t pos;
Double_t x[100],yl1[100],yl2[100],yl3[100],yl4[100],yl5[100],yl6[100],yl7[100];
Int_t Flag[6]=0;
FILE *fp = fopen(FileName,"r");
if ( fp == NULL ){
@ -36,12 +37,11 @@ void plotFrc(char *FileName)
if ( nline==0 ){
// First line, get data labels
nline++;
token = line.Tokenize(" ");
ntokens = token->GetEntries();
labels = line.Tokenize(" ");
ntokens = labels->GetEntries();
nPars=ntokens;
ostr = dynamic_cast<TObjString*>(token->At(0));
ostr = dynamic_cast<TObjString*>(labels->At(0));
xlab = ostr->GetString();
ostr = dynamic_cast<TObjString*>(token->At(10));
ylab = ostr->GetString();
} else {
@ -58,68 +58,117 @@ void plotFrc(char *FileName)
strtoken = (TObjString*) token->At(10);
label = strtoken->GetName();
yl1[i] = label.Atof();
printf("(x,y)[%d]= (%f,%f)\n",i,x[i],yl1[i]);
if (yl1[i]>0) { Flag[0]=1;}
strtoken = (TObjString*) token->At(11);
label = strtoken->GetName();
yl2[i] = label.Atof();
if (yl2[i]>0) { Flag[1]=1;}
strtoken = (TObjString*) token->At(12);
label = strtoken->GetName();
yl3[i] = label.Atof();
if (yl3[i]>0) { Flag[2]=1;}
strtoken = (TObjString*) token->At(13);
label = strtoken->GetName();
yl4[i] = label.Atof();
if (yl4[i]>0) { Flag[3]=1;}
strtoken = (TObjString*) token->At(14);
label = strtoken->GetName();
yl5[i] = label.Atof();
if (yl5[i]>0) { Flag[4]=1;}
strtoken = (TObjString*) token->At(15);
label = strtoken->GetName();
yl6[i] = label.Atof();
if (yl6[i]>0) { Flag[5]=1;}
strtoken = (TObjString*) token->At(16);
label = strtoken->GetName();
yl7[i] = label.Atof();
if (yl7[i]>0) { Flag[6]=1;}
//}
// delete token;
nline++;
i++;
}
}
TCanvas *c = new TCanvas("c",str);
TCanvas *c = new TCanvas("c",str);
c->Show();
TLegend *legend = new TLegend(0.8, 0.8, 0.95, 0.95);
legend->SetFillColor(TColor::GetColor(255,255,255)); // white
TGraph *gr1 = new TGraph(i-1,x,yl1);
gr1->GetXaxis()->SetTitle(xlab);
gr1->GetYaxis()->SetTitle(ylab);
gr1->Draw("AC*");
if (Flag[0]==1){
TGraph *gr1 = new TGraph(i-1,x,yl1);
gr1->GetXaxis()->SetTitle(xlab);
gr1->GetYaxis()->SetTitle("Implanted Fraction");
gr1->Draw("APC");
gr1->SetMarkerStyle(20);
gr1->SetMarkerColor(TColor::kRed);
gr1->SetLineColor(TColor::kRed);
legend->AddEntry(gr1,"Layer 1");
}
TGraph *gr2 = new TGraph(i-1,x,yl2);
gr2->Draw("C*");
if (Flag[1]==1){
TGraph *gr2 = new TGraph(i-1,x,yl2);
gr2->SetMarkerStyle(20);
gr2->SetMarkerColor(TColor::kGreen);
gr2->SetLineColor(TColor::kGreen);
gr2->Draw("PC");
legend->AddEntry(gr2,"Layer 2");
}
TGraph *gr3 = new TGraph(i-1,x,yl3);
gr3->Draw("C*");
if (Flag[2]==1){
TGraph *gr3 = new TGraph(i-1,x,yl3);
gr3->SetMarkerStyle(20);
gr3->SetMarkerColor(TColor::kBlue);
gr3->SetLineColor(TColor::kBlue);
gr3->Draw("PC");
legend->AddEntry(gr3,"Layer 3");
}
TGraph *gr4 = new TGraph(i-1,x,yl4);
gr4->Draw("C*");
if (Flag[3]==1){
TGraph *gr4 = new TGraph(i-1,x,yl4);
gr4->SetMarkerStyle(20);
gr4->SetMarkerColor(TColor::kMagenta);
gr4->SetLineColor(TColor::kMagenta);
gr4->Draw("PC");
legend->AddEntry(gr4,"Layer 4");
}
TGraph *gr5 = new TGraph(i-1,x,yl5);
gr5->Draw("C*");
if (Flag[4]==1){
TGraph *gr5 = new TGraph(i-1,x,yl5);
gr5->SetMarkerStyle(20);
gr5->SetMarkerColor(TColor::kOrange);
gr5->SetLineColor(TColor::kOrange);
gr5->Draw("PC");
legend->AddEntry(gr5,"Layer 5");
}
TGraph *gr6 = new TGraph(i-1,x,yl6);
gr6->Draw("C*");
TGraph *gr7 = new TGraph(i-1,x,yl7);
gr7->Draw("C*");
c->Show();
if (Flag[5]==1){
TGraph *gr6 = new TGraph(i-1,x,yl6);
gr6->SetMarkerStyle(20);
gr6->SetMarkerColor(TColor::kViolet);
gr6->SetLineColor(TColor::kViolet);
gr6->Draw("PC");
legend->AddEntry(gr6,"Layer 6");
}
if (Flag[6]==1){
TGraph *gr7 = new TGraph(i-1,x,yl7);
gr7->SetMarkerStyle(20);
gr7->SetMarkerColor(TColor::kAzure+7);
gr7->SetLineColor(TColor::kAzure+7);
gr7->Draw("PC");
legend->AddEntry(gr7,"Layer 7");
}
legend->Draw();
// I am not sure what this does, but it waits until canvas is closed
c->WaitPrimitive(" ");

View File

@ -160,6 +160,7 @@ void plotRge(TString &names)
rge[i]->SetLineColor(color[i]);
} else {
TRandom *rand = new TRandom(i);
col = TColor::GetColor((Int_t)rand->Integer(255),(Int_t)rand->Integer(255),(Int_t)rand->Integer(255));
rge[i]->SetMarkerColor(col);
rge[i]->SetLineColor(col);