More work towards plotting implantation profiles.
This commit is contained in:
148
trimsp/TrimSPGUI/plotRge.C
Normal file
148
trimsp/TrimSPGUI/plotRge.C
Normal file
@ -0,0 +1,148 @@
|
||||
// File: plotRge.C
|
||||
// Author: Andreas Suter
|
||||
// Date: 03/06/2009
|
||||
// Purpose: ROOT macro to read and plot Range data from trimsp calculation
|
||||
// Assume following file Format:
|
||||
// Very simple at the moment...
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
// DEPTH PARTICLES
|
||||
// 15. 260
|
||||
// 45. 595
|
||||
// 75. 820
|
||||
// 105. 1179
|
||||
//
|
||||
// plotRge(names), e.g.
|
||||
// plotRge("InSne_E2500, InSne_E4000");
|
||||
// will read files
|
||||
|
||||
void plotRge(TString &names)
|
||||
{
|
||||
if (names.CompareTo("help", TString::kIgnoreCase) == 0) {
|
||||
cout << endl << "usage: plotRge(<names>) or plotRge(\"help\")";
|
||||
cout << endl << " <names> is a list of rge-files";
|
||||
cout << endl << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
TObjArray *tokens;
|
||||
TObjString *ostr;
|
||||
TString str;
|
||||
char cstr[128];
|
||||
|
||||
Int_t i, j;
|
||||
Int_t nStep = 0;
|
||||
Double_t *depth;
|
||||
Double_t *nStop;
|
||||
Double_t norm;
|
||||
Double_t intNorm;
|
||||
Double_t normStop[1000];
|
||||
|
||||
TGraph *rge[1000];
|
||||
|
||||
tokens = names.Tokenize(" \t,;");
|
||||
|
||||
Double_t min = 0, max = 0;
|
||||
|
||||
for (i=0; i<tokens->GetEntries(); i++) {
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(i));
|
||||
str = ostr->GetString();
|
||||
cout << endl << i << ": read " << str.Data();
|
||||
|
||||
TGraph *fileGraph = new TGraph(str);
|
||||
if ( fileGraph->IsZombie() ){
|
||||
cout << endl;
|
||||
cout << "File " << str << " does not exist!!!" << endl << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
depth = fileGraph->GetX();
|
||||
nStop = fileGraph->GetY();
|
||||
nStep = fileGraph->GetN();
|
||||
|
||||
// calculate stops/nm
|
||||
norm = depth[1] - depth[0];
|
||||
|
||||
intNorm = 0.0;
|
||||
for (j=0; j<nStep; j++) {
|
||||
intNorm += nStop[j];
|
||||
}
|
||||
|
||||
for (j=0; j<nStep; j++) {
|
||||
if (norm > 0.) {
|
||||
normStop[j] = nStop[j]/norm*10.0/intNorm;
|
||||
} else {
|
||||
normStop[j] = -1.;
|
||||
}
|
||||
depth[j] = depth[j]/10.; // scale depth to nm
|
||||
|
||||
if (normStop[j] > max)
|
||||
max = normStop[j];
|
||||
if (normStop[j] < min)
|
||||
min = normStop[j];
|
||||
}
|
||||
|
||||
rge[i] = new TGraph(nStep, depth, normStop);
|
||||
|
||||
ostr = dynamic_cast<TObjString*>(tokens->At(i));
|
||||
str = ostr->GetString() + ", ";
|
||||
sprintf(cstr, "%.1lf", ostr->GetString().Atof() /1000.0);
|
||||
str += cstr;
|
||||
str += " (keV)";
|
||||
rge[i]->SetTitle(str.Data());
|
||||
rge[i]->SetFillColor(TColor::kWhite);
|
||||
|
||||
delete fileGraph;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
Int_t color[1000];
|
||||
for (i=0; i<1000; i++)
|
||||
color[i] = -1;
|
||||
color[0] = TColor::kRed;
|
||||
color[1] = TColor::kGreen;
|
||||
color[2] = TColor::kBlue;
|
||||
color[3] = TColor::kMagenta;
|
||||
color[4] = TColor::kOrange;
|
||||
color[5] = TColor::kViolet;
|
||||
color[6] = TColor::kAzure+7;
|
||||
color[7] = TColor::kOrange+4;
|
||||
color[8] = TColor::kBlue-7;
|
||||
|
||||
Int_t last = tokens->GetEntries()-1;
|
||||
rge[last]->SetMarkerStyle(20);
|
||||
rge[last]->GetXaxis()->SetTitle("depth (nm)");
|
||||
rge[last]->GetYaxis()->SetTitle("normalized stopping distribution (nm^{-1})");
|
||||
|
||||
TCanvas *c1 = new TCanvas("c1", "rge plot");
|
||||
c1->Show();
|
||||
|
||||
rge[last]->Draw("apl");
|
||||
rge[last]->GetYaxis()->SetRangeUser(min, 1.05*max);
|
||||
|
||||
Int_t col;
|
||||
for (i=0; i<last; i++) {
|
||||
if (color[i] >= 0) {
|
||||
rge[i]->SetMarkerColor(color[i]);
|
||||
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);
|
||||
delete rand;
|
||||
}
|
||||
rge[i]->SetMarkerStyle(20);
|
||||
rge[i]->Draw("plsame");
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
delete tokens;
|
||||
}
|
Reference in New Issue
Block a user