static const double cm=1;
static const double volt=1;
static const double Qe=-1.6e-19*
C;
static const double epsilonGe=15.8;
double V(double *coordinates, double *parameters)
{
double x = coordinates[0];
double x1= parameters[0];
double v1= parameters[1];
double rho=parameters[2]*
Qe;
double c2= (v1-v0)/(x1-x0) - a/2*(x1+x0);
double c1= (v0*x1-v1*x0)/(x1-x0) + a/2*x0*x1;
return a*x*x/2 + c2*x + c1;
}
double GetVdep(double impurity, double thickness, double vupper)
{
if (impurity==0) return 0;
TF1 *det=new TF1("det", V, 0, thickness, 3);
double bias, vlower=0*
volt;
while (abs(vupper-vlower)>1e-3*
volt) {
bias=(vupper+vlower)/2;
det->SetParameters(thickness, bias, impurity);
if (det->Derivative(0)*det->Derivative(thickness)<0) vlower=bias;
else vupper=bias;
}
return bias;
}
void getVd(
int type=1,
double thickness=1*
cm)
{
const int n=10;
if (type==-1) for (int i=0; i<n; i++) impurity[i]*=type;
double absi[n], vdep[n];
for (int i=0; i<n; i++) {
vdep[i] = GetVdep(impurity[i], thickness, type*-2e4*
volt);
absi[i] = abs(impurity[i]);
}
gROOT->SetStyle("Plain");
gStyle->SetLegendBorderSize(0);
gStyle->SetLegendFont(132);
gStyle->SetLabelFont(132,"XY");
gStyle->SetTitleFont(132,"XY");
gStyle->SetLabelSize(0.05,"XY");
gStyle->SetTitleSize(0.05,"XY");
gStyle->SetTitleOffset(1.1,"XY");
gStyle->SetPadRightMargin(0.01);
gStyle->SetPadLeftMargin(0.11);
gStyle->SetPadTopMargin(0.01);
gStyle->SetPadBottomMargin(0.12);
TGraph *g = new TGraph(n,absi,vdep);
g->SetTitle(";Net Impurity [cm^{-3}];Depletion Voltage [V]");
g->Draw("apc");
TText *t1 = new TText(2e9, 6000,
Form(
"%.0f cm thick planar detector", thickness/
cm));
t1->Draw();
gPad->SetLogx(); gPad->SetGridx(); gPad->SetGridy();
gPad->Print("depleted.png");
double bias = -1000*
volt*type;
TCanvas *c = new TCanvas;
TF1 *fvo=new TF1("fvo", V, 0, thickness, 3);
fvo->SetParameters(thickness, vdep[6]+bias, impurity[6]);
fvo->SetTitle(";Vertical position in planar detector [cm]; Voltage [V]");
fvo->SetLineColor(kMagenta);
fvo->SetLineStyle(2);
fvo->GetXaxis()->SetTitleOffset(1.1);
fvo->Draw();
TF1 *fvd=new TF1("fvd", V, 0, thickness, 3);
fvd->SetParameters(thickness, vdep[6], impurity[6]);
fvd->Draw("same");
TF1 *fvu=new TF1("fvu", V, 0, thickness, 3);
fvu->SetParameters(thickness, bias, impurity[6]);
fvu->SetLineColor(kRed);
fvu->SetLineStyle(3);
fvu->Draw("same");
TF1 *fvb=new TF1("fvb", V, 0, thickness, 3);
fvb->SetParameters(thickness, bias, 0/
cm3);
fvb->SetLineColor(kBlue);
fvb->SetLineStyle(4);
fvb->Draw("same");
TF1 *fvc=new TF1("fvc", V, 0, thickness, 3);
fvc->SetParameters(thickness, 0*
volt, impurity[6]);
fvc->SetLineColor(kGreen);
fvc->SetLineStyle(5);
fvc->Draw("same");
if (type==-1) {
TLine *l1 =
new TLine(0,bias/
volt,thickness/
cm,bias/
volt);
l1->SetLineStyle(kDashed); l1->Draw();
TLine *l2 =
new TLine(0,vdep[6]/
volt,thickness/
cm,vdep[6]/
volt);
l2->SetLineStyle(kDashed); l2->Draw();
TLine *l3=
new TLine(0,(vdep[6]+bias)/
volt,thickness/
cm,(vdep[6]+bias)/
volt);
l3->SetLineStyle(kDashed); l3->Draw();
TText *t2 =
new TText(0.04,bias/
volt+20,Form(
"%.0f V", bias/
volt));
t2->SetTextFont(132); t2->Draw();
TText *t3 =
new TText(0.04,vdep[6]/
volt+20, Form(
"%.0f V", vdep[6]/
volt));
t3->SetTextFont(132); t3->Draw();
TText *t4 =
new TText(0.04,(vdep[6]+bias)/
volt+20,
Form(
"%.0f V", (vdep[6]+bias)/
volt));
t4->Draw();
TText *t5 = new TText(0.5, 2800, "over depleted");
t5->SetTextFont(132); t5->SetTextColor(kMagenta); t5->Draw();
TText *t6 = new TText(0.8, 2310, "just depleted");
t6->SetTextFont(132); t6->Draw();
TText *t7 = new TText(0.65, 1250, "undepleted");
t7->SetTextFont(132); t7->SetTextColor(kRed); t7->Draw();
TText *t8 = new TText(0.65, 800, "bias alone");
t8->SetTextFont(132); t8->SetTextColor(kBlue); t8->Draw();
TText *t9 = new TText(0.55, 200, "space charges alone");
t9->SetTextFont(132); t9->SetTextColor(kGreen); t9->Draw();
TLatex *t10 = new TLatex(0.1, 2700,
Form(
"Impurity: %.0e/cm^{3}",impurity[6]/
cm3));
t10->SetTextFont(132); t10->Draw();
} else {
TLine *l0 =
new TLine(0,0,thickness/
cm,0);
l0->SetLineStyle(kDashed); l0->Draw();
TLine *l1 =
new TLine(0,bias/
volt,thickness/
cm,bias/
volt);
l1->SetLineStyle(kDashed); l1->Draw();
TLine *l2 =
new TLine(0,vdep[6]/
volt,thickness/
cm,vdep[6]/
volt);
l2->SetLineStyle(kDashed); l2->Draw();
TLine *l3=
new TLine(0,(vdep[6]+bias)/
volt,thickness/
cm,(vdep[6]+bias)/
volt);
l3->SetLineStyle(kDashed); l3->Draw();
TText *t2 =
new TText(0.04,bias/
volt+20,Form(
"%.0f V", bias/
volt));
t2->SetTextFont(132); t2->Draw();
TText *t3 =
new TText(0.04,vdep[6]/
volt+20, Form(
"%.0f V", vdep[6]/
volt));
t3->SetTextFont(132); t3->Draw();
TText *t4 =
new TText(0.04,(vdep[6]+bias)/
volt+20,
Form(
"%.0f V", (vdep[6]+bias)/
volt));
t4->SetTextFont(132); t4->Draw();
TText *t5 = new TText(0.76, -2850, "over depleted");
t5->SetTextFont(132); t5->SetTextAngle(-19); t5->SetTextColor(kMagenta);
t5->Draw();
TText *t6 = new TText(0.8, -2120, "just depleted");
t6->SetTextFont(132); t6->SetTextAngle(-9); t6->Draw();
TText *t7 = new TText(0.65, -1350, "undepleted");
t7->SetTextFont(132); t7->SetTextColor(kRed); t7->Draw();
TText *t8 = new TText(0.75, -700, "bias alone");
t8->SetTextFont(132); t8->SetTextAngle(-11.5); t8->SetTextColor(kBlue);
t8->Draw();
TText *t9 = new TText(0.65, -450, "space charges alone");
t9->SetTextFont(132); t9->SetTextAngle(12.5); t9->SetTextColor(kGreen);
t9->Draw();
TLatex *t10 = new TLatex(0.15, -2800,
Form(
"Impurity: %.0e/cm^{3}",impurity[6]/
cm3));
t10->SetTextFont(132); t10->Draw();
}
c->Print("undepleted.png");
}