# TPC charge distribution fit to power law

For many years, we have used the following distribution to model space charge in the TPC, taken from StRoot/StDbUtilities/StMagUtilities.cxx:

`Charge(i,j) = zterm * ( 3191/(Radius*Radius) + 122.5/Radius - 0.395 ) / 15823 ;`

If we try to fit this distribution with 1/rN, we find N=1.71. Here I use 14 bins in radius (coarse binning) and 280 bins (fine binning) in a simple Monte Carlo simulation:  My code (how2pow.C):

```Double_t how2pow(Int_t throws=10000000,Int_t nbins=14) {
gStyle->SetOptDate(0);
gStyle->SetGridColor(kGray);

Double_t guess0 = 3000.0*((Double_t) throws)/((Double_t) nbins);
Double_t guess1 = 1.75;

TF1* powfunc = new TF1("powfunc","/pow(x,)",60,200);
powfunc->SetParameter(0,guess0);
powfunc->SetParameter(1,guess1);
powfunc->SetLineColor(2);
printf("Guesses: %g/r^%g\n",guess0,guess1);

TF1* howfunc = new TF1("howfunc","3191/(x*x)+(122.5/x)-0.395",60,200);

TH1D* howhist = new TH1D("hist","charge distribution",nbins,60,200);
howhist->SetXTitle("radius [cm]");
howhist->SetMinimum(0);
howhist->SetLineColor(4);
howhist->SetLineWidth(2);
howhist->FillRandom("howfunc",throws);
howhist->Fit(powfunc);

double N = powfunc->GetParameter(1);

return N;
}

///////////////////////

Processing how2pow.C(1e7,14)...
Guesses: 2.14286e+09/r^1.75
FCN=12611.2 FROM MIGRAD    STATUS=CONVERGED      68 CALLS          69 TOTAL
EDM=1.17285e-08    STRATEGY= 1      ERROR MATRIX ACCURATE
EXT PARAMETER                                   STEP         FIRST
NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
1  p0           2.27902e+09   9.51785e+06   1.08672e+03  -4.33372e-11
2  p1           1.71146e+00   9.02537e-04   3.74986e-06   6.21831e-01
(Double_t)1.71146365615700979e+00

///////////////////////

Processing how2pow.C(1e7,280)...
Guesses: 1.07143e+08/r^1.75
FCN=13354 FROM MIGRAD    STATUS=CONVERGED      77 CALLS          78 TOTAL
EDM=3.25874e-11    STRATEGY= 1      ERROR MATRIX ACCURATE
EXT PARAMETER                                   STEP         FIRST
NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
1  p0           1.12629e+08   4.66121e+05   3.22630e+02  -2.24815e-11
2  p1           1.70946e+00   8.94802e-04   3.86066e-06   2.06545e-02
(Double_t)1.70945568207506549e+00

```

-Gene

Groups: