Added plot mean depth and straggeling function
This commit is contained in:
parent
767bbd51cf
commit
e38656de85
116
trimsp/src/TrimSPGUI4/plotMean.C
Normal file
116
trimsp/src/TrimSPGUI4/plotMean.C
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
// File: plotMean.C
|
||||||
|
// Author: Zaher Salman
|
||||||
|
// Date: 27/08/2014
|
||||||
|
// Purpose: ROOT macro to read and plot implantation fractions in layers from trimsp calculation
|
||||||
|
// Assume following file Format:
|
||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Energy SigmaE Alpha SigAlpha ntot imp backsc trans tried negE impL1 impL2 impL3 impL4 impL5 impL6 impL7 range straggeling Eback sigEback Etrans SigEtrans red. E PRC
|
||||||
|
// 15.00 0.45 0.00 15.00 100000 98362 1638 0 100000 0 98362 0 0 0 0 0 0 0.6664E+03 0.1799E+03 0.4980E+04 0.4250E+04 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
|
||||||
|
// plotFrc(file_name)
|
||||||
|
|
||||||
|
void plotMean(char *FileName)
|
||||||
|
{
|
||||||
|
TObjString *ostr;
|
||||||
|
TString str,xlab,ylab;
|
||||||
|
|
||||||
|
TString line, label, treeLabel;
|
||||||
|
TString rootFileName;
|
||||||
|
TObjArray *token,*labels;
|
||||||
|
TObjString *strtoken;
|
||||||
|
Int_t nPars = 0;
|
||||||
|
Int_t ntokens = 0;
|
||||||
|
Int_t i = 0;
|
||||||
|
Int_t nline=0;
|
||||||
|
Int_t intNorm=0;
|
||||||
|
Ssiz_t pos;
|
||||||
|
Double_t x[100],mean[100],strag[100];
|
||||||
|
|
||||||
|
FILE *fp = fopen(FileName,"r");
|
||||||
|
if ( fp == NULL ){
|
||||||
|
printf("File %s does not exist!\n", FileName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (line.Gets(fp)){
|
||||||
|
if ( nline==0 ){
|
||||||
|
// First line, get data labels
|
||||||
|
nline++;
|
||||||
|
labels = line.Tokenize(" ");
|
||||||
|
ntokens = labels->GetEntries();
|
||||||
|
nPars=ntokens;
|
||||||
|
ostr = dynamic_cast<TObjString*>(labels->At(0));
|
||||||
|
xlab = ostr->GetString();
|
||||||
|
ylab = ostr->GetString();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
token = line.Tokenize(" ");
|
||||||
|
ntokens = token->GetEntries();
|
||||||
|
|
||||||
|
// This is the energy
|
||||||
|
// Plots for other scanned parameters need to be treated differently
|
||||||
|
strtoken = (TObjString*) token->At(0);
|
||||||
|
label = strtoken->GetName();
|
||||||
|
x[i] = label.Atof();
|
||||||
|
|
||||||
|
// Mean is column 17 and straggeling 18
|
||||||
|
// This is mean implantation depth values
|
||||||
|
strtoken = (TObjString*) token->At(17);
|
||||||
|
label = strtoken->GetName();
|
||||||
|
mean[i] = label.Atof()/10.;
|
||||||
|
if (mean[i]>0) {
|
||||||
|
intNorm = intNorm++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is straggeling
|
||||||
|
strtoken = (TObjString*) token->At(18);
|
||||||
|
label = strtoken->GetName();
|
||||||
|
strag[i] = label.Atof()/10.;
|
||||||
|
if (strag[i]>0) {
|
||||||
|
intNorm = intNorm++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nline++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
TMultiGraph *mg = new TMultiGraph();
|
||||||
|
|
||||||
|
TGraph *gr1 = new TGraph(i,x,mean);
|
||||||
|
gr1->GetXaxis()->SetTitle(xlab);
|
||||||
|
gr1->GetYaxis()->SetTitle("Mean depth and straggeling");
|
||||||
|
// gr1->Draw("APC");
|
||||||
|
gr1->SetMarkerStyle(20);
|
||||||
|
gr1->SetMarkerColor(TColor::kRed);
|
||||||
|
gr1->SetLineColor(TColor::kRed);
|
||||||
|
legend->AddEntry(gr1,"Mean");
|
||||||
|
mg->Add(gr1);
|
||||||
|
|
||||||
|
TGraph *gr2 = new TGraph(i,x,strag);
|
||||||
|
gr2->SetMarkerStyle(20);
|
||||||
|
gr2->SetMarkerColor(TColor::kGreen);
|
||||||
|
gr2->SetLineColor(TColor::kGreen);
|
||||||
|
legend->AddEntry(gr2,"Strag.");
|
||||||
|
mg->Add(gr2);
|
||||||
|
|
||||||
|
mg->Draw("APC");
|
||||||
|
mg->GetXaxis()->SetTitle("Energy [keV]");
|
||||||
|
mg->GetYaxis()->SetTitle("Mean depth/Straggeling [nm]");
|
||||||
|
legend->Draw();
|
||||||
|
|
||||||
|
// I am not sure what this does, but it waits until canvas is closed
|
||||||
|
c->WaitPrimitive(" ");
|
||||||
|
cout << endl << "Canvas Closed" << endl ;
|
||||||
|
|
||||||
|
// Then quit root cleanly
|
||||||
|
gApplication->Terminate();
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user