From 496806a0ad3493776c4ee16446ac98c6713a88c4 Mon Sep 17 00:00:00 2001 From: Zaher Salman Date: Thu, 12 Jan 2012 08:42:16 +0000 Subject: [PATCH] Added plotting implanted fractions in each layer (Not normalized). --- trimsp/TrimSPGUI/plotFrc.C | 131 +++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 trimsp/TrimSPGUI/plotFrc.C diff --git a/trimsp/TrimSPGUI/plotFrc.C b/trimsp/TrimSPGUI/plotFrc.C new file mode 100644 index 0000000..1563ba7 --- /dev/null +++ b/trimsp/TrimSPGUI/plotFrc.C @@ -0,0 +1,131 @@ +// File: plotFrc.C +// Author: Zaher Salman +// Date: 11/01/2012 +// 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 plotFrc(char *FileName) +{ + TObjString *ostr; + TString str,xlab,ylab; + + TString line, label, treeLabel; + TString rootFileName; + TObjArray *token; + TObjString *strtoken; + Int_t nPars = 0; + Int_t ntokens = 0; + Int_t i = 0; + 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]; + + 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++; + token = line.Tokenize(" "); + ntokens = token->GetEntries(); + nPars=ntokens; + ostr = dynamic_cast(token->At(0)); + xlab = ostr->GetString(); + ostr = dynamic_cast(token->At(10)); + ylab = ostr->GetString(); + + } else { + token = line.Tokenize(" "); + ntokens = token->GetEntries(); + + strtoken = (TObjString*) token->At(0); + label = strtoken->GetName(); + x[i] = label.Atof(); + + // Plot all layers for now. Maybe stop when sum is zero in the future + // Layers start from column # 10 up to 16. + // for (col=10;col<17;col++) { + strtoken = (TObjString*) token->At(10); + label = strtoken->GetName(); + yl1[i] = label.Atof(); + printf("(x,y)[%d]= (%f,%f)\n",i,x[i],yl1[i]); + + strtoken = (TObjString*) token->At(11); + label = strtoken->GetName(); + yl2[i] = label.Atof(); + + strtoken = (TObjString*) token->At(12); + label = strtoken->GetName(); + yl3[i] = label.Atof(); + + strtoken = (TObjString*) token->At(13); + label = strtoken->GetName(); + yl4[i] = label.Atof(); + + strtoken = (TObjString*) token->At(14); + label = strtoken->GetName(); + yl5[i] = label.Atof(); + + strtoken = (TObjString*) token->At(15); + label = strtoken->GetName(); + yl6[i] = label.Atof(); + + strtoken = (TObjString*) token->At(16); + label = strtoken->GetName(); + yl7[i] = label.Atof(); + + //} + // delete token; + nline++; + i++; + } + } + + + TCanvas *c = new TCanvas("c",str); + + TGraph *gr1 = new TGraph(i-1,x,yl1); + gr1->GetXaxis()->SetTitle(xlab); + gr1->GetYaxis()->SetTitle(ylab); + gr1->Draw("AC*"); + + TGraph *gr2 = new TGraph(i-1,x,yl2); + gr2->Draw("C*"); + + TGraph *gr3 = new TGraph(i-1,x,yl3); + gr3->Draw("C*"); + + TGraph *gr4 = new TGraph(i-1,x,yl4); + gr4->Draw("C*"); + + TGraph *gr5 = new TGraph(i-1,x,yl5); + gr5->Draw("C*"); + + TGraph *gr6 = new TGraph(i-1,x,yl6); + gr6->Draw("C*"); + + TGraph *gr7 = new TGraph(i-1,x,yl7); + gr7->Draw("C*"); + + c->Show(); + + + + // 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(); +} +